﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using MyLib;

namespace Billing
{
    /// <summary>
    /// DBCommands
    /// <example>This example shows how to use DBCommands:
    /// <code>
    /// <newpara/>
    /// DBCommands db = new DBCommands(connection_string);
    /// <newpara/>
    /// </code>
    /// </example>
    /// </summary>
	public class DBCommands : MyLib.DBCommandsBase
	{
		public DBCommands(string connectString) : base(connectString) { }

        /// <summary>
        /// DBCommands
        /// <example>This example shows how to use transaction:
        /// <code>
        /// <newpara/>
        /// try
        /// {
        ///    Common.db.ExceptionMode = true;
        ///    Common.db.BeginTransaction();
        ///    Common.db.ExecSqlCmd(@"update t1 set name = @name where id=@id", name, id1);
        ///    Common.db.ExecSqlCmd(......);
        ///    Common.db.Commit();
        /// }
        /// catch (Exception ex)
        /// {
        ///    Common.db.Rollback();
        ///    MessageBox.Show(ex.ExceptionInfo());
        /// }
        /// finally
        /// {
        ///    Common.db.ExceptionMode = false;
        /// }
        /// <newpara/>
        /// </code>
        /// </example>
        /// </summary>

		#region AuditTrail
		//**********************************************************
		//  AuditTrail
		//**********************************************************
        CMD_AuditTrail m_AuditTrail = null;
        public CMD_AuditTrail AuditTrail
        {
            get
            {
				if (m_AuditTrail == null)
					m_AuditTrail = new CMD_AuditTrail(this);
				return m_AuditTrail;
			}
        }

		[Serializable]
		public class TBL_AuditTrail
		{
			public int Id { get; set; }
			public DateTime DateTime { get; set; }
			public string Script { get; set; }
			public string User { get; set; }
			public string Action { get; set; }
			public string Table { get; set; }
			public string Field { get; set; }
			public string KeyValue { get; set; }
			public string OldValue { get; set; }
			public string NewValue { get; set; }

			public TBL_AuditTrail()
			{
				this.Id = 0;
				this.DateTime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.Script = "";
				this.User = "";
				this.Action = "";
				this.Table = "";
				this.Field = "";
				this.KeyValue = "";
				this.OldValue = "";
				this.NewValue = "";
			}

			public TBL_AuditTrail(int Id, DateTime DateTime, string Script, string User, string Action, string Table, string Field, string KeyValue, string OldValue, string NewValue)
			{
				this.Id = Id;
				this.DateTime = DateTime;
				this.Script = Script;
				this.User = User;
				this.Action = Action;
				this.Table = Table;
				this.Field = Field;
				this.KeyValue = KeyValue;
				this.OldValue = OldValue;
				this.NewValue = NewValue;
			}

			public void CopyTo(ref TBL_AuditTrail to)
			{
				to.Id = this.Id;
				to.DateTime = this.DateTime;
				to.Script = this.Script;
				to.User = this.User;
				to.Action = this.Action;
				to.Table = this.Table;
				to.Field = this.Field;
				to.KeyValue = this.KeyValue;
				to.OldValue = this.OldValue;
				to.NewValue = this.NewValue;
			}

			public bool IsSame(TBL_AuditTrail x)
			{
				return(
					this.Id == x.Id &&
					this.DateTime == x.DateTime &&
					this.Script == x.Script &&
					this.User == x.User &&
					this.Action == x.Action &&
					this.Table == x.Table &&
					this.Field == x.Field &&
					this.KeyValue == x.KeyValue &&
					this.OldValue == x.OldValue &&
					this.NewValue == x.NewValue
				);
			}

			public static TBL_AuditTrail ReadRow(DataRow row)
			{
				TBL_AuditTrail record = new TBL_AuditTrail();
				record.Id = get_int_value(row["Id"]);
				record.DateTime = get_DateTime_value(row["DateTime"]);
				record.Script = get_string_value(row["Script"]);
				record.User = get_string_value(row["User"]);
				record.Action = get_string_value(row["Action"]);
				record.Table = get_string_value(row["Table"]);
				record.Field = get_string_value(row["Field"]);
				record.KeyValue = get_string_value(row["KeyValue"]);
				record.OldValue = get_string_value(row["OldValue"]);
				record.NewValue = get_string_value(row["NewValue"]);
				return record;
			}

			public static List<TBL_AuditTrail> ReadTable(DataTable dt)
			{
				List<TBL_AuditTrail> records = new List<TBL_AuditTrail>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_AuditTrail
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_AuditTrail(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int Id,
				ref TBL_AuditTrail data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select Id, DateTime, Script, User, Action, Table, Field, KeyValue, OldValue, NewValue
					from AuditTrail
					where Id=@Id
					", ref dt, Id))
                {
                    m_db.LastError = "AuditTrail.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "AuditTrail.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_AuditTrail.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int Id,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select AuditTrail.Id, AuditTrail.DateTime, AuditTrail.Script, AuditTrail.User, AuditTrail.Action, AuditTrail.Table, AuditTrail.Field, AuditTrail.KeyValue, AuditTrail.OldValue, AuditTrail.NewValue
					from AuditTrail
					where AuditTrail.Id=@Id
					", ref dt, Id);
                if (!_ok) m_db.LastError = "AuditTrail.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Id, DateTime, Script, User, Action, Table, Field, KeyValue, OldValue, NewValue
					from AuditTrail
					", ref dt);
                if (!_ok) m_db.LastError = "AuditTrail.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "AuditTrail.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select AuditTrail.Id, AuditTrail.DateTime, AuditTrail.Script, AuditTrail.User, AuditTrail.Action, AuditTrail.Table, AuditTrail.Field, AuditTrail.KeyValue, AuditTrail.OldValue, AuditTrail.NewValue
					from AuditTrail
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "AuditTrail.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select AuditTrail.Id, AuditTrail.DateTime, AuditTrail.Script, AuditTrail.User, AuditTrail.Action, AuditTrail.Table, AuditTrail.Field, AuditTrail.KeyValue, AuditTrail.OldValue, AuditTrail.NewValue
					from AuditTrail
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "AuditTrail.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				DateTime DateTime,
				string Script,
				string User,
				string Action,
				string Table,
				string Field,
				string KeyValue,
				string OldValue,
				string NewValue
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into AuditTrail(
						DateTime,
						Script,
						User,
						Action,
						Table,
						Field,
						KeyValue,
						OldValue,
						NewValue
						)
					values(
						@DateTime,
						@Script,
						@User,
						@Action,
						@Table,
						@Field,
						@KeyValue,
						@OldValue,
						@NewValue
						)
					", DateTime, Script, User, Action, Table, Field, KeyValue, OldValue, NewValue);
                if (!_ok) m_db.LastError = "AuditTrail.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int Id,
				DateTime DateTime,
				string Script,
				string User,
				string Action,
				string Table,
				string Field,
				string KeyValue,
				string OldValue,
				string NewValue
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from AuditTrail where Id=@Id", ref count, Id))
				{
					m_db.LastError = "AuditTrail.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "AuditTrail.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update AuditTrail
					set
						DateTime = @DateTime,
						Script = @Script,
						User = @User,
						Action = @Action,
						Table = @Table,
						Field = @Field,
						KeyValue = @KeyValue,
						OldValue = @OldValue,
						NewValue = @NewValue
					where Id=@Id
					",
					DateTime,
					Script,
					User,
					Action,
					Table,
					Field,
					KeyValue,
					OldValue,
					NewValue,
					Id
				);
                if (!_ok) m_db.LastError = "AuditTrail.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int Id
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from AuditTrail where Id=@Id", ref count, Id))
				{
					m_db.LastError = "AuditTrail.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "AuditTrail.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from AuditTrail where Id=@Id", Id);
                if (!_ok) m_db.LastError = "AuditTrail.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region Bill
		//**********************************************************
		//  Bill
		//**********************************************************
        CMD_Bill m_Bill = null;
        public CMD_Bill Bill
        {
            get
            {
				if (m_Bill == null)
					m_Bill = new CMD_Bill(this);
				return m_Bill;
			}
        }

		[Serializable]
		public class TBL_Bill
		{
			public int ID { get; set; }
			public int BillPeriodID { get; set; }
			public string BillType { get; set; }
			public DateTime BillDate { get; set; }
			public int AgencyID { get; set; }
			public int BUID { get; set; }
			public int CostCentreID { get; set; }
			public int ResourceManagerID { get; set; }
			public int ComputerID { get; set; }
			public int ServiceRequestID { get; set; }
			public int ServiceRequestType { get; set; }
			public DateTime DoDate { get; set; }
			public decimal Price { get; set; }
			public string Remarks { get; set; }

			public TBL_Bill()
			{
				this.ID = 0;
				this.BillPeriodID = 0;
				this.BillType = "";
				this.BillDate = Convert.ToDateTime("1900-01-01 00:00:00");
				this.AgencyID = 0;
				this.BUID = 0;
				this.CostCentreID = 0;
				this.ResourceManagerID = 0;
				this.ComputerID = 0;
				this.ServiceRequestID = 0;
				this.ServiceRequestType = 0;
				this.DoDate = Convert.ToDateTime("1900-01-01 00:00:00");
				this.Price = 0M;
				this.Remarks = "";
			}

			public TBL_Bill(int ID, int BillPeriodID, string BillType, DateTime BillDate, int AgencyID, int BUID, int CostCentreID, int ResourceManagerID, int ComputerID, int ServiceRequestID, int ServiceRequestType, DateTime DoDate, decimal Price, string Remarks)
			{
				this.ID = ID;
				this.BillPeriodID = BillPeriodID;
				this.BillType = BillType;
				this.BillDate = BillDate;
				this.AgencyID = AgencyID;
				this.BUID = BUID;
				this.CostCentreID = CostCentreID;
				this.ResourceManagerID = ResourceManagerID;
				this.ComputerID = ComputerID;
				this.ServiceRequestID = ServiceRequestID;
				this.ServiceRequestType = ServiceRequestType;
				this.DoDate = DoDate;
				this.Price = Price;
				this.Remarks = Remarks;
			}

			public void CopyTo(ref TBL_Bill to)
			{
				to.ID = this.ID;
				to.BillPeriodID = this.BillPeriodID;
				to.BillType = this.BillType;
				to.BillDate = this.BillDate;
				to.AgencyID = this.AgencyID;
				to.BUID = this.BUID;
				to.CostCentreID = this.CostCentreID;
				to.ResourceManagerID = this.ResourceManagerID;
				to.ComputerID = this.ComputerID;
				to.ServiceRequestID = this.ServiceRequestID;
				to.ServiceRequestType = this.ServiceRequestType;
				to.DoDate = this.DoDate;
				to.Price = this.Price;
				to.Remarks = this.Remarks;
			}

			public bool IsSame(TBL_Bill x)
			{
				return(
					this.ID == x.ID &&
					this.BillPeriodID == x.BillPeriodID &&
					this.BillType == x.BillType &&
					this.BillDate == x.BillDate &&
					this.AgencyID == x.AgencyID &&
					this.BUID == x.BUID &&
					this.CostCentreID == x.CostCentreID &&
					this.ResourceManagerID == x.ResourceManagerID &&
					this.ComputerID == x.ComputerID &&
					this.ServiceRequestID == x.ServiceRequestID &&
					this.ServiceRequestType == x.ServiceRequestType &&
					this.DoDate == x.DoDate &&
					this.Price == x.Price &&
					this.Remarks == x.Remarks
				);
			}

			public static TBL_Bill ReadRow(DataRow row)
			{
				TBL_Bill record = new TBL_Bill();
				record.ID = get_int_value(row["ID"]);
				record.BillPeriodID = get_int_value(row["BillPeriodID"]);
				record.BillType = get_string_value(row["BillType"]);
				record.BillDate = get_DateTime_value(row["BillDate"]);
				record.AgencyID = get_int_value(row["AgencyID"]);
				record.BUID = get_int_value(row["BUID"]);
				record.CostCentreID = get_int_value(row["CostCentreID"]);
				record.ResourceManagerID = get_int_value(row["ResourceManagerID"]);
				record.ComputerID = get_int_value(row["ComputerID"]);
				record.ServiceRequestID = get_int_value(row["ServiceRequestID"]);
				record.ServiceRequestType = get_int_value(row["ServiceRequestType"]);
				record.DoDate = get_DateTime_value(row["DoDate"]);
				record.Price = get_decimal_value(row["Price"]);
				record.Remarks = get_string_value(row["Remarks"]);
				return record;
			}

			public static List<TBL_Bill> ReadTable(DataTable dt)
			{
				List<TBL_Bill> records = new List<TBL_Bill>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_Bill
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_Bill(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_Bill data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, BillPeriodID, BillType, BillDate, AgencyID, BUID, CostCentreID, ResourceManagerID, ComputerID, ServiceRequestID, ServiceRequestType, DoDate, Price, Remarks
					from Bill
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "Bill.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "Bill.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_Bill.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Bill.ID, Bill.BillPeriodID, Bill.BillType, Bill.BillDate, Bill.AgencyID, Bill.BUID, Bill.CostCentreID, Bill.ResourceManagerID, Bill.ComputerID, Bill.ServiceRequestID, Bill.ServiceRequestType, Bill.DoDate, Bill.Price, Bill.Remarks
					from Bill
					where Bill.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "Bill.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, BillPeriodID, BillType, BillDate, AgencyID, BUID, CostCentreID, ResourceManagerID, ComputerID, ServiceRequestID, ServiceRequestType, DoDate, Price, Remarks
					from Bill
					", ref dt);
                if (!_ok) m_db.LastError = "Bill.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "Bill.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Bill.ID, Bill.BillPeriodID, Bill.BillType, Bill.BillDate, Bill.AgencyID, Bill.BUID, Bill.CostCentreID, Bill.ResourceManagerID, Bill.ComputerID, Bill.ServiceRequestID, Bill.ServiceRequestType, Bill.DoDate, Bill.Price, Bill.Remarks
					from Bill
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "Bill.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Bill.ID, Bill.BillPeriodID, Bill.BillType, Bill.BillDate, Bill.AgencyID, Bill.BUID, Bill.CostCentreID, Bill.ResourceManagerID, Bill.ComputerID, Bill.ServiceRequestID, Bill.ServiceRequestType, Bill.DoDate, Bill.Price, Bill.Remarks
					from Bill
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "Bill.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int BillPeriodID,
				string BillType,
				DateTime BillDate,
				int AgencyID,
				int BUID,
				int CostCentreID,
				int ResourceManagerID,
				int ComputerID,
				int ServiceRequestID,
				int ServiceRequestType,
				DateTime DoDate,
				decimal Price,
				string Remarks
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into Bill(
						BillPeriodID,
						BillType,
						BillDate,
						AgencyID,
						BUID,
						CostCentreID,
						ResourceManagerID,
						ComputerID,
						ServiceRequestID,
						ServiceRequestType,
						DoDate,
						Price,
						Remarks
						)
					values(
						@BillPeriodID,
						@BillType,
						@BillDate,
						@AgencyID,
						@BUID,
						@CostCentreID,
						@ResourceManagerID,
						@ComputerID,
						@ServiceRequestID,
						@ServiceRequestType,
						@DoDate,
						@Price,
						@Remarks
						)
					", BillPeriodID, BillType, BillDate, AgencyID, BUID, CostCentreID, ResourceManagerID, ComputerID, ServiceRequestID, ServiceRequestType, DoDate, Price, Remarks);
                if (!_ok) m_db.LastError = "Bill.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				int BillPeriodID,
				string BillType,
				DateTime BillDate,
				int AgencyID,
				int BUID,
				int CostCentreID,
				int ResourceManagerID,
				int ComputerID,
				int ServiceRequestID,
				int ServiceRequestType,
				DateTime DoDate,
				decimal Price,
				string Remarks
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from Bill where ID=@ID", ref count, ID))
				{
					m_db.LastError = "Bill.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "Bill.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update Bill
					set
						BillPeriodID = @BillPeriodID,
						BillType = @BillType,
						BillDate = @BillDate,
						AgencyID = @AgencyID,
						BUID = @BUID,
						CostCentreID = @CostCentreID,
						ResourceManagerID = @ResourceManagerID,
						ComputerID = @ComputerID,
						ServiceRequestID = @ServiceRequestID,
						ServiceRequestType = @ServiceRequestType,
						DoDate = @DoDate,
						Price = @Price,
						Remarks = @Remarks
					where ID=@ID
					",
					BillPeriodID,
					BillType,
					BillDate,
					AgencyID,
					BUID,
					CostCentreID,
					ResourceManagerID,
					ComputerID,
					ServiceRequestID,
					ServiceRequestType,
					DoDate,
					Price,
					Remarks,
					ID
				);
                if (!_ok) m_db.LastError = "Bill.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from Bill where ID=@ID", ref count, ID))
				{
					m_db.LastError = "Bill.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "Bill.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from Bill where ID=@ID", ID);
                if (!_ok) m_db.LastError = "Bill.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region BillPeriod
		//**********************************************************
		//  BillPeriod
		//**********************************************************
        CMD_BillPeriod m_BillPeriod = null;
        public CMD_BillPeriod BillPeriod
        {
            get
            {
				if (m_BillPeriod == null)
					m_BillPeriod = new CMD_BillPeriod(this);
				return m_BillPeriod;
			}
        }

		[Serializable]
		public class TBL_BillPeriod
		{
			public int ID { get; set; }
			public string Year0 { get; set; }
			public string Month0 { get; set; }
			public DateTime StartDate { get; set; }
			public DateTime EndDate { get; set; }

			public TBL_BillPeriod()
			{
				this.ID = 0;
				this.Year0 = "";
				this.Month0 = "";
				this.StartDate = Convert.ToDateTime("1900-01-01 00:00:00");
				this.EndDate = Convert.ToDateTime("1900-01-01 00:00:00");
			}

			public TBL_BillPeriod(int ID, string Year0, string Month0, DateTime StartDate, DateTime EndDate)
			{
				this.ID = ID;
				this.Year0 = Year0;
				this.Month0 = Month0;
				this.StartDate = StartDate;
				this.EndDate = EndDate;
			}

			public void CopyTo(ref TBL_BillPeriod to)
			{
				to.ID = this.ID;
				to.Year0 = this.Year0;
				to.Month0 = this.Month0;
				to.StartDate = this.StartDate;
				to.EndDate = this.EndDate;
			}

			public bool IsSame(TBL_BillPeriod x)
			{
				return(
					this.ID == x.ID &&
					this.Year0 == x.Year0 &&
					this.Month0 == x.Month0 &&
					this.StartDate == x.StartDate &&
					this.EndDate == x.EndDate
				);
			}

			public static TBL_BillPeriod ReadRow(DataRow row)
			{
				TBL_BillPeriod record = new TBL_BillPeriod();
				record.ID = get_int_value(row["ID"]);
				record.Year0 = get_string_value(row["Year0"]);
				record.Month0 = get_string_value(row["Month0"]);
				record.StartDate = get_DateTime_value(row["StartDate"]);
				record.EndDate = get_DateTime_value(row["EndDate"]);
				return record;
			}

			public static List<TBL_BillPeriod> ReadTable(DataTable dt)
			{
				List<TBL_BillPeriod> records = new List<TBL_BillPeriod>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_BillPeriod
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_BillPeriod(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_BillPeriod data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, Year0, Month0, StartDate, EndDate
					from BillPeriod
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "BillPeriod.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "BillPeriod.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_BillPeriod.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select BillPeriod.ID, BillPeriod.Year0, BillPeriod.Month0, BillPeriod.StartDate, BillPeriod.EndDate
					from BillPeriod
					where BillPeriod.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "BillPeriod.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, Year0, Month0, StartDate, EndDate
					from BillPeriod
					", ref dt);
                if (!_ok) m_db.LastError = "BillPeriod.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "BillPeriod.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select BillPeriod.ID, BillPeriod.Year0, BillPeriod.Month0, BillPeriod.StartDate, BillPeriod.EndDate
					from BillPeriod
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "BillPeriod.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select BillPeriod.ID, BillPeriod.Year0, BillPeriod.Month0, BillPeriod.StartDate, BillPeriod.EndDate
					from BillPeriod
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "BillPeriod.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				string Year0,
				string Month0,
				DateTime StartDate,
				DateTime EndDate
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into BillPeriod(
						Year0,
						Month0,
						StartDate,
						EndDate
						)
					values(
						@Year0,
						@Month0,
						@StartDate,
						@EndDate
						)
					", Year0, Month0, StartDate, EndDate);
                if (!_ok) m_db.LastError = "BillPeriod.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				string Year0,
				string Month0,
				DateTime StartDate,
				DateTime EndDate
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from BillPeriod where ID=@ID", ref count, ID))
				{
					m_db.LastError = "BillPeriod.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "BillPeriod.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update BillPeriod
					set
						Year0 = @Year0,
						Month0 = @Month0,
						StartDate = @StartDate,
						EndDate = @EndDate
					where ID=@ID
					",
					Year0,
					Month0,
					StartDate,
					EndDate,
					ID
				);
                if (!_ok) m_db.LastError = "BillPeriod.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from BillPeriod where ID=@ID", ref count, ID))
				{
					m_db.LastError = "BillPeriod.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "BillPeriod.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from BillPeriod where ID=@ID", ID);
                if (!_ok) m_db.LastError = "BillPeriod.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region BillReportRepository
		//**********************************************************
		//  BillReportRepository
		//**********************************************************
        CMD_BillReportRepository m_BillReportRepository = null;
        public CMD_BillReportRepository BillReportRepository
        {
            get
            {
				if (m_BillReportRepository == null)
					m_BillReportRepository = new CMD_BillReportRepository(this);
				return m_BillReportRepository;
			}
        }

		[Serializable]
		public class TBL_BillReportRepository
		{
			public int ID { get; set; }
			public int BillPeriodID { get; set; }
			public int BillReportTemplateID { get; set; }
			public string ReportFileName { get; set; }
			public object ReportData { get; set; }
			public string ContentType { get; set; }
			public int IsReleased { get; set; }
			public int BUID { get; set; }
			public int CostCentreID { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDateTime { get; set; }
			public int ReleasedBy { get; set; }
			public DateTime ReleasedDateTime { get; set; }
			public string DownloadID { get; set; }
			public int UnReleasedBy { get; set; }
			public DateTime UnReleasedDateTime { get; set; }
			public int BillCustomerID { get; set; }

			public TBL_BillReportRepository()
			{
				this.ID = 0;
				this.BillPeriodID = 0;
				this.BillReportTemplateID = 0;
				this.ReportFileName = "";
				this.ReportData = null;
				this.ContentType = "";
				this.IsReleased = 0;
				this.BUID = 0;
				this.CostCentreID = 0;
				this.CreatedBy = 0;
				this.CreatedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ReleasedBy = 0;
				this.ReleasedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.DownloadID = "";
				this.UnReleasedBy = 0;
				this.UnReleasedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.BillCustomerID = 0;
			}

			public TBL_BillReportRepository(int ID, int BillPeriodID, int BillReportTemplateID, string ReportFileName, object ReportData, string ContentType, int IsReleased, int BUID, int CostCentreID, int CreatedBy, DateTime CreatedDateTime, int ReleasedBy, DateTime ReleasedDateTime, string DownloadID, int UnReleasedBy, DateTime UnReleasedDateTime, int BillCustomerID)
			{
				this.ID = ID;
				this.BillPeriodID = BillPeriodID;
				this.BillReportTemplateID = BillReportTemplateID;
				this.ReportFileName = ReportFileName;
				this.ReportData = ReportData;
				this.ContentType = ContentType;
				this.IsReleased = IsReleased;
				this.BUID = BUID;
				this.CostCentreID = CostCentreID;
				this.CreatedBy = CreatedBy;
				this.CreatedDateTime = CreatedDateTime;
				this.ReleasedBy = ReleasedBy;
				this.ReleasedDateTime = ReleasedDateTime;
				this.DownloadID = DownloadID;
				this.UnReleasedBy = UnReleasedBy;
				this.UnReleasedDateTime = UnReleasedDateTime;
				this.BillCustomerID = BillCustomerID;
			}

			public void CopyTo(ref TBL_BillReportRepository to)
			{
				to.ID = this.ID;
				to.BillPeriodID = this.BillPeriodID;
				to.BillReportTemplateID = this.BillReportTemplateID;
				to.ReportFileName = this.ReportFileName;
				to.ReportData = this.ReportData;
				to.ContentType = this.ContentType;
				to.IsReleased = this.IsReleased;
				to.BUID = this.BUID;
				to.CostCentreID = this.CostCentreID;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDateTime = this.CreatedDateTime;
				to.ReleasedBy = this.ReleasedBy;
				to.ReleasedDateTime = this.ReleasedDateTime;
				to.DownloadID = this.DownloadID;
				to.UnReleasedBy = this.UnReleasedBy;
				to.UnReleasedDateTime = this.UnReleasedDateTime;
				to.BillCustomerID = this.BillCustomerID;
			}

			public bool IsSame(TBL_BillReportRepository x)
			{
				return(
					this.ID == x.ID &&
					this.BillPeriodID == x.BillPeriodID &&
					this.BillReportTemplateID == x.BillReportTemplateID &&
					this.ReportFileName == x.ReportFileName &&
					this.ReportData == x.ReportData &&
					this.ContentType == x.ContentType &&
					this.IsReleased == x.IsReleased &&
					this.BUID == x.BUID &&
					this.CostCentreID == x.CostCentreID &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDateTime == x.CreatedDateTime &&
					this.ReleasedBy == x.ReleasedBy &&
					this.ReleasedDateTime == x.ReleasedDateTime &&
					this.DownloadID == x.DownloadID &&
					this.UnReleasedBy == x.UnReleasedBy &&
					this.UnReleasedDateTime == x.UnReleasedDateTime &&
					this.BillCustomerID == x.BillCustomerID
				);
			}

			public static TBL_BillReportRepository ReadRow(DataRow row)
			{
				TBL_BillReportRepository record = new TBL_BillReportRepository();
				record.ID = get_int_value(row["ID"]);
				record.BillPeriodID = get_int_value(row["BillPeriodID"]);
				record.BillReportTemplateID = get_int_value(row["BillReportTemplateID"]);
				record.ReportFileName = get_string_value(row["ReportFileName"]);
				record.ReportData = get_object_value(row["ReportData"]);
				record.ContentType = get_string_value(row["ContentType"]);
				record.IsReleased = get_int_value(row["IsReleased"]);
				record.BUID = get_int_value(row["BUID"]);
				record.CostCentreID = get_int_value(row["CostCentreID"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDateTime = get_DateTime_value(row["CreatedDateTime"]);
				record.ReleasedBy = get_int_value(row["ReleasedBy"]);
				record.ReleasedDateTime = get_DateTime_value(row["ReleasedDateTime"]);
				record.DownloadID = get_string_value(row["DownloadID"]);
				record.UnReleasedBy = get_int_value(row["UnReleasedBy"]);
				record.UnReleasedDateTime = get_DateTime_value(row["UnReleasedDateTime"]);
				record.BillCustomerID = get_int_value(row["BillCustomerID"]);
				return record;
			}

			public static List<TBL_BillReportRepository> ReadTable(DataTable dt)
			{
				List<TBL_BillReportRepository> records = new List<TBL_BillReportRepository>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_BillReportRepository
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_BillReportRepository(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_BillReportRepository data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, BillPeriodID, BillReportTemplateID, ReportFileName, ReportData, ContentType, IsReleased, BUID, CostCentreID, CreatedBy, CreatedDateTime, ReleasedBy, ReleasedDateTime, DownloadID, UnReleasedBy, UnReleasedDateTime, BillCustomerID
					from BillReportRepository
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "BillReportRepository.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "BillReportRepository.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_BillReportRepository.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select BillReportRepository.ID, BillReportRepository.BillPeriodID, BillReportRepository.BillReportTemplateID, BillReportRepository.ReportFileName, BillReportRepository.ReportData, BillReportRepository.ContentType, BillReportRepository.IsReleased, BillReportRepository.BUID, BillReportRepository.CostCentreID, BillReportRepository.CreatedBy, BillReportRepository.CreatedDateTime, BillReportRepository.ReleasedBy, BillReportRepository.ReleasedDateTime, BillReportRepository.DownloadID, BillReportRepository.UnReleasedBy, BillReportRepository.UnReleasedDateTime, BillReportRepository.BillCustomerID
					from BillReportRepository
					where BillReportRepository.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "BillReportRepository.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, BillPeriodID, BillReportTemplateID, ReportFileName, ReportData, ContentType, IsReleased, BUID, CostCentreID, CreatedBy, CreatedDateTime, ReleasedBy, ReleasedDateTime, DownloadID, UnReleasedBy, UnReleasedDateTime, BillCustomerID
					from BillReportRepository
					", ref dt);
                if (!_ok) m_db.LastError = "BillReportRepository.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "BillReportRepository.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select BillReportRepository.ID, BillReportRepository.BillPeriodID, BillReportRepository.BillReportTemplateID, BillReportRepository.ReportFileName, BillReportRepository.ReportData, BillReportRepository.ContentType, BillReportRepository.IsReleased, BillReportRepository.BUID, BillReportRepository.CostCentreID, BillReportRepository.CreatedBy, BillReportRepository.CreatedDateTime, BillReportRepository.ReleasedBy, BillReportRepository.ReleasedDateTime, BillReportRepository.DownloadID, BillReportRepository.UnReleasedBy, BillReportRepository.UnReleasedDateTime, BillReportRepository.BillCustomerID
					from BillReportRepository
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "BillReportRepository.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select BillReportRepository.ID, BillReportRepository.BillPeriodID, BillReportRepository.BillReportTemplateID, BillReportRepository.ReportFileName, BillReportRepository.ReportData, BillReportRepository.ContentType, BillReportRepository.IsReleased, BillReportRepository.BUID, BillReportRepository.CostCentreID, BillReportRepository.CreatedBy, BillReportRepository.CreatedDateTime, BillReportRepository.ReleasedBy, BillReportRepository.ReleasedDateTime, BillReportRepository.DownloadID, BillReportRepository.UnReleasedBy, BillReportRepository.UnReleasedDateTime, BillReportRepository.BillCustomerID
					from BillReportRepository
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "BillReportRepository.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int BillPeriodID,
				int BillReportTemplateID,
				string ReportFileName,
				object ReportData,
				string ContentType,
				int IsReleased,
				int BUID,
				int CostCentreID,
				int CreatedBy,
				DateTime CreatedDateTime,
				int ReleasedBy,
				DateTime ReleasedDateTime,
				string DownloadID,
				int UnReleasedBy,
				DateTime UnReleasedDateTime,
				int BillCustomerID
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into BillReportRepository(
						BillPeriodID,
						BillReportTemplateID,
						ReportFileName,
						ReportData,
						ContentType,
						IsReleased,
						BUID,
						CostCentreID,
						CreatedBy,
						CreatedDateTime,
						ReleasedBy,
						ReleasedDateTime,
						DownloadID,
						UnReleasedBy,
						UnReleasedDateTime,
						BillCustomerID
						)
					values(
						@BillPeriodID,
						@BillReportTemplateID,
						@ReportFileName,
						@ReportData,
						@ContentType,
						@IsReleased,
						@BUID,
						@CostCentreID,
						@CreatedBy,
						@CreatedDateTime,
						@ReleasedBy,
						@ReleasedDateTime,
						@DownloadID,
						@UnReleasedBy,
						@UnReleasedDateTime,
						@BillCustomerID
						)
					", BillPeriodID, BillReportTemplateID, ReportFileName, ReportData, ContentType, IsReleased, BUID, CostCentreID, CreatedBy, CreatedDateTime, ReleasedBy, ReleasedDateTime, DownloadID, UnReleasedBy, UnReleasedDateTime, BillCustomerID);
                if (!_ok) m_db.LastError = "BillReportRepository.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				int BillPeriodID,
				int BillReportTemplateID,
				string ReportFileName,
				object ReportData,
				string ContentType,
				int IsReleased,
				int BUID,
				int CostCentreID,
				int CreatedBy,
				DateTime CreatedDateTime,
				int ReleasedBy,
				DateTime ReleasedDateTime,
				string DownloadID,
				int UnReleasedBy,
				DateTime UnReleasedDateTime,
				int BillCustomerID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from BillReportRepository where ID=@ID", ref count, ID))
				{
					m_db.LastError = "BillReportRepository.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "BillReportRepository.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update BillReportRepository
					set
						BillPeriodID = @BillPeriodID,
						BillReportTemplateID = @BillReportTemplateID,
						ReportFileName = @ReportFileName,
						ReportData = @ReportData,
						ContentType = @ContentType,
						IsReleased = @IsReleased,
						BUID = @BUID,
						CostCentreID = @CostCentreID,
						CreatedBy = @CreatedBy,
						CreatedDateTime = @CreatedDateTime,
						ReleasedBy = @ReleasedBy,
						ReleasedDateTime = @ReleasedDateTime,
						DownloadID = @DownloadID,
						UnReleasedBy = @UnReleasedBy,
						UnReleasedDateTime = @UnReleasedDateTime,
						BillCustomerID = @BillCustomerID
					where ID=@ID
					",
					BillPeriodID,
					BillReportTemplateID,
					ReportFileName,
					ReportData,
					ContentType,
					IsReleased,
					BUID,
					CostCentreID,
					CreatedBy,
					CreatedDateTime,
					ReleasedBy,
					ReleasedDateTime,
					DownloadID,
					UnReleasedBy,
					UnReleasedDateTime,
					BillCustomerID,
					ID
				);
                if (!_ok) m_db.LastError = "BillReportRepository.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from BillReportRepository where ID=@ID", ref count, ID))
				{
					m_db.LastError = "BillReportRepository.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "BillReportRepository.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from BillReportRepository where ID=@ID", ID);
                if (!_ok) m_db.LastError = "BillReportRepository.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region BillReportTemplate
		//**********************************************************
		//  BillReportTemplate
		//**********************************************************
        CMD_BillReportTemplate m_BillReportTemplate = null;
        public CMD_BillReportTemplate BillReportTemplate
        {
            get
            {
				if (m_BillReportTemplate == null)
					m_BillReportTemplate = new CMD_BillReportTemplate(this);
				return m_BillReportTemplate;
			}
        }

		[Serializable]
		public class TBL_BillReportTemplate
		{
			public int ID { get; set; }
			public string ReportName { get; set; }
			public string ReportPath { get; set; }
			public string RenderFormat { get; set; }
			public string ReportFileExt { get; set; }
			public string ContentType { get; set; }
			public string DatasetName { get; set; }
			public string StoredProcName { get; set; }
			public string ParameterType { get; set; }
			public int ReportStatus { get; set; }
			public string BillType { get; set; }

			public TBL_BillReportTemplate()
			{
				this.ID = 0;
				this.ReportName = "";
				this.ReportPath = "";
				this.RenderFormat = "";
				this.ReportFileExt = "";
				this.ContentType = "";
				this.DatasetName = "";
				this.StoredProcName = "";
				this.ParameterType = "";
				this.ReportStatus = 0;
				this.BillType = "";
			}

			public TBL_BillReportTemplate(int ID, string ReportName, string ReportPath, string RenderFormat, string ReportFileExt, string ContentType, string DatasetName, string StoredProcName, string ParameterType, int ReportStatus, string BillType)
			{
				this.ID = ID;
				this.ReportName = ReportName;
				this.ReportPath = ReportPath;
				this.RenderFormat = RenderFormat;
				this.ReportFileExt = ReportFileExt;
				this.ContentType = ContentType;
				this.DatasetName = DatasetName;
				this.StoredProcName = StoredProcName;
				this.ParameterType = ParameterType;
				this.ReportStatus = ReportStatus;
				this.BillType = BillType;
			}

			public void CopyTo(ref TBL_BillReportTemplate to)
			{
				to.ID = this.ID;
				to.ReportName = this.ReportName;
				to.ReportPath = this.ReportPath;
				to.RenderFormat = this.RenderFormat;
				to.ReportFileExt = this.ReportFileExt;
				to.ContentType = this.ContentType;
				to.DatasetName = this.DatasetName;
				to.StoredProcName = this.StoredProcName;
				to.ParameterType = this.ParameterType;
				to.ReportStatus = this.ReportStatus;
				to.BillType = this.BillType;
			}

			public bool IsSame(TBL_BillReportTemplate x)
			{
				return(
					this.ID == x.ID &&
					this.ReportName == x.ReportName &&
					this.ReportPath == x.ReportPath &&
					this.RenderFormat == x.RenderFormat &&
					this.ReportFileExt == x.ReportFileExt &&
					this.ContentType == x.ContentType &&
					this.DatasetName == x.DatasetName &&
					this.StoredProcName == x.StoredProcName &&
					this.ParameterType == x.ParameterType &&
					this.ReportStatus == x.ReportStatus &&
					this.BillType == x.BillType
				);
			}

			public static TBL_BillReportTemplate ReadRow(DataRow row)
			{
				TBL_BillReportTemplate record = new TBL_BillReportTemplate();
				record.ID = get_int_value(row["ID"]);
				record.ReportName = get_string_value(row["ReportName"]);
				record.ReportPath = get_string_value(row["ReportPath"]);
				record.RenderFormat = get_string_value(row["RenderFormat"]);
				record.ReportFileExt = get_string_value(row["ReportFileExt"]);
				record.ContentType = get_string_value(row["ContentType"]);
				record.DatasetName = get_string_value(row["DatasetName"]);
				record.StoredProcName = get_string_value(row["StoredProcName"]);
				record.ParameterType = get_string_value(row["ParameterType"]);
				record.ReportStatus = get_int_value(row["ReportStatus"]);
				record.BillType = get_string_value(row["BillType"]);
				return record;
			}

			public static List<TBL_BillReportTemplate> ReadTable(DataTable dt)
			{
				List<TBL_BillReportTemplate> records = new List<TBL_BillReportTemplate>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_BillReportTemplate
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_BillReportTemplate(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_BillReportTemplate data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, ReportName, ReportPath, RenderFormat, ReportFileExt, ContentType, DatasetName, StoredProcName, ParameterType, ReportStatus, BillType
					from BillReportTemplate
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "BillReportTemplate.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "BillReportTemplate.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_BillReportTemplate.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select BillReportTemplate.ID, BillReportTemplate.ReportName, BillReportTemplate.ReportPath, BillReportTemplate.RenderFormat, BillReportTemplate.ReportFileExt, BillReportTemplate.ContentType, BillReportTemplate.DatasetName, BillReportTemplate.StoredProcName, BillReportTemplate.ParameterType, BillReportTemplate.ReportStatus, BillReportTemplate.BillType
					from BillReportTemplate
					where BillReportTemplate.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "BillReportTemplate.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, ReportName, ReportPath, RenderFormat, ReportFileExt, ContentType, DatasetName, StoredProcName, ParameterType, ReportStatus, BillType
					from BillReportTemplate
					", ref dt);
                if (!_ok) m_db.LastError = "BillReportTemplate.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "BillReportTemplate.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select BillReportTemplate.ID, BillReportTemplate.ReportName, BillReportTemplate.ReportPath, BillReportTemplate.RenderFormat, BillReportTemplate.ReportFileExt, BillReportTemplate.ContentType, BillReportTemplate.DatasetName, BillReportTemplate.StoredProcName, BillReportTemplate.ParameterType, BillReportTemplate.ReportStatus, BillReportTemplate.BillType
					from BillReportTemplate
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "BillReportTemplate.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select BillReportTemplate.ID, BillReportTemplate.ReportName, BillReportTemplate.ReportPath, BillReportTemplate.RenderFormat, BillReportTemplate.ReportFileExt, BillReportTemplate.ContentType, BillReportTemplate.DatasetName, BillReportTemplate.StoredProcName, BillReportTemplate.ParameterType, BillReportTemplate.ReportStatus, BillReportTemplate.BillType
					from BillReportTemplate
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "BillReportTemplate.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int ID,
				string ReportName,
				string ReportPath,
				string RenderFormat,
				string ReportFileExt,
				string ContentType,
				string DatasetName,
				string StoredProcName,
				string ParameterType,
				int ReportStatus,
				string BillType
			)
			{            
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from BillReportTemplate where ID=@ID", ref count, ID))
				{
					m_db.LastError = "BillReportTemplate.insert error.\r\n" + m_db.LastError;
					return false;
				}
				if (count > 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "BillReportTemplate.insert error. ID duplicate";
					return false;
				}

				bool _ok = m_db.ExecSqlCmd(@"
					insert into BillReportTemplate(
						ID,
						ReportName,
						ReportPath,
						RenderFormat,
						ReportFileExt,
						ContentType,
						DatasetName,
						StoredProcName,
						ParameterType,
						ReportStatus,
						BillType
						)
					values(
						@ID,
						@ReportName,
						@ReportPath,
						@RenderFormat,
						@ReportFileExt,
						@ContentType,
						@DatasetName,
						@StoredProcName,
						@ParameterType,
						@ReportStatus,
						@BillType
						)
					", ID, ReportName, ReportPath, RenderFormat, ReportFileExt, ContentType, DatasetName, StoredProcName, ParameterType, ReportStatus, BillType);
                if (!_ok) m_db.LastError = "BillReportTemplate.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int _old_ID,
				int _new_ID,
				string ReportName,
				string ReportPath,
				string RenderFormat,
				string ReportFileExt,
				string ContentType,
				string DatasetName,
				string StoredProcName,
				string ParameterType,
				int ReportStatus,
				string BillType
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from BillReportTemplate where ID=@_old_ID", ref count, _old_ID))
				{
					m_db.LastError = "BillReportTemplate.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "BillReportTemplate.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update BillReportTemplate
					set
						ID = @_new_ID,
						ReportName = @ReportName,
						ReportPath = @ReportPath,
						RenderFormat = @RenderFormat,
						ReportFileExt = @ReportFileExt,
						ContentType = @ContentType,
						DatasetName = @DatasetName,
						StoredProcName = @StoredProcName,
						ParameterType = @ParameterType,
						ReportStatus = @ReportStatus,
						BillType = @BillType
					where ID=@_old_ID
					",
					_new_ID,
					ReportName,
					ReportPath,
					RenderFormat,
					ReportFileExt,
					ContentType,
					DatasetName,
					StoredProcName,
					ParameterType,
					ReportStatus,
					BillType,
					_old_ID
				);
                if (!_ok) m_db.LastError = "BillReportTemplate.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from BillReportTemplate where ID=@ID", ref count, ID))
				{
					m_db.LastError = "BillReportTemplate.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "BillReportTemplate.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from BillReportTemplate where ID=@ID", ID);
                if (!_ok) m_db.LastError = "BillReportTemplate.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region ComputerInResourceManager
		//**********************************************************
		//  ComputerInResourceManager
		//**********************************************************
        CMD_ComputerInResourceManager m_ComputerInResourceManager = null;
        public CMD_ComputerInResourceManager ComputerInResourceManager
        {
            get
            {
				if (m_ComputerInResourceManager == null)
					m_ComputerInResourceManager = new CMD_ComputerInResourceManager(this);
				return m_ComputerInResourceManager;
			}
        }

		[Serializable]
		public class TBL_ComputerInResourceManager
		{
			public int ID { get; set; }
			public int ResourceManagerID { get; set; }
			public string ComputerName { get; set; }
			public string OperatingSystem { get; set; }
			public string IpAddress { get; set; }
			public string ServerName { get; set; }
			public int Status { get; set; }

			public TBL_ComputerInResourceManager()
			{
				this.ID = 0;
				this.ResourceManagerID = 0;
				this.ComputerName = "";
				this.OperatingSystem = "";
				this.IpAddress = "";
				this.ServerName = "";
				this.Status = 0;
			}

			public TBL_ComputerInResourceManager(int ID, int ResourceManagerID, string ComputerName, string OperatingSystem, string IpAddress, string ServerName, int Status)
			{
				this.ID = ID;
				this.ResourceManagerID = ResourceManagerID;
				this.ComputerName = ComputerName;
				this.OperatingSystem = OperatingSystem;
				this.IpAddress = IpAddress;
				this.ServerName = ServerName;
				this.Status = Status;
			}

			public void CopyTo(ref TBL_ComputerInResourceManager to)
			{
				to.ID = this.ID;
				to.ResourceManagerID = this.ResourceManagerID;
				to.ComputerName = this.ComputerName;
				to.OperatingSystem = this.OperatingSystem;
				to.IpAddress = this.IpAddress;
				to.ServerName = this.ServerName;
				to.Status = this.Status;
			}

			public bool IsSame(TBL_ComputerInResourceManager x)
			{
				return(
					this.ID == x.ID &&
					this.ResourceManagerID == x.ResourceManagerID &&
					this.ComputerName == x.ComputerName &&
					this.OperatingSystem == x.OperatingSystem &&
					this.IpAddress == x.IpAddress &&
					this.ServerName == x.ServerName &&
					this.Status == x.Status
				);
			}

			public static TBL_ComputerInResourceManager ReadRow(DataRow row)
			{
				TBL_ComputerInResourceManager record = new TBL_ComputerInResourceManager();
				record.ID = get_int_value(row["ID"]);
				record.ResourceManagerID = get_int_value(row["ResourceManagerID"]);
				record.ComputerName = get_string_value(row["ComputerName"]);
				record.OperatingSystem = get_string_value(row["OperatingSystem"]);
				record.IpAddress = get_string_value(row["IpAddress"]);
				record.ServerName = get_string_value(row["ServerName"]);
				record.Status = get_int_value(row["Status"]);
				return record;
			}

			public static List<TBL_ComputerInResourceManager> ReadTable(DataTable dt)
			{
				List<TBL_ComputerInResourceManager> records = new List<TBL_ComputerInResourceManager>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_ComputerInResourceManager
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_ComputerInResourceManager(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}



			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, ResourceManagerID, ComputerName, OperatingSystem, IpAddress, ServerName, Status
					from ComputerInResourceManager
					", ref dt);
                if (!_ok) m_db.LastError = "ComputerInResourceManager.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "ComputerInResourceManager.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ComputerInResourceManager.ID, ComputerInResourceManager.ResourceManagerID, ComputerInResourceManager.ComputerName, ComputerInResourceManager.OperatingSystem, ComputerInResourceManager.IpAddress, ComputerInResourceManager.ServerName, ComputerInResourceManager.Status
					from ComputerInResourceManager
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "ComputerInResourceManager.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ComputerInResourceManager.ID, ComputerInResourceManager.ResourceManagerID, ComputerInResourceManager.ComputerName, ComputerInResourceManager.OperatingSystem, ComputerInResourceManager.IpAddress, ComputerInResourceManager.ServerName, ComputerInResourceManager.Status
					from ComputerInResourceManager
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "ComputerInResourceManager.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int ID,
				int ResourceManagerID,
				string ComputerName,
				string OperatingSystem,
				string IpAddress,
				string ServerName,
				int Status
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into ComputerInResourceManager(
						ID,
						ResourceManagerID,
						ComputerName,
						OperatingSystem,
						IpAddress,
						ServerName,
						Status
						)
					values(
						@ID,
						@ResourceManagerID,
						@ComputerName,
						@OperatingSystem,
						@IpAddress,
						@ServerName,
						@Status
						)
					", ID, ResourceManagerID, ComputerName, OperatingSystem, IpAddress, ServerName, Status);
                if (!_ok) m_db.LastError = "ComputerInResourceManager.insert error.\r\n" + m_db.LastError;
                return _ok;
			}


        
		}

		#endregion

		#region Configuration
		//**********************************************************
		//  Configuration
		//**********************************************************
        CMD_Configuration m_Configuration = null;
        public CMD_Configuration Configuration
        {
            get
            {
				if (m_Configuration == null)
					m_Configuration = new CMD_Configuration(this);
				return m_Configuration;
			}
        }

		[Serializable]
		public class TBL_Configuration
		{
			public int ID { get; set; }
			public string ConfigurationName { get; set; }
			public string ConfigurationValue { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public int ModifiedBy { get; set; }
			public DateTime ModifiedDatetime { get; set; }

			public TBL_Configuration()
			{
				this.ID = 0;
				this.ConfigurationName = "";
				this.ConfigurationValue = "";
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ModifiedBy = 0;
				this.ModifiedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
			}

			public TBL_Configuration(int ID, string ConfigurationName, string ConfigurationValue, int CreatedBy, DateTime CreatedDatetime, int ModifiedBy, DateTime ModifiedDatetime)
			{
				this.ID = ID;
				this.ConfigurationName = ConfigurationName;
				this.ConfigurationValue = ConfigurationValue;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.ModifiedBy = ModifiedBy;
				this.ModifiedDatetime = ModifiedDatetime;
			}

			public void CopyTo(ref TBL_Configuration to)
			{
				to.ID = this.ID;
				to.ConfigurationName = this.ConfigurationName;
				to.ConfigurationValue = this.ConfigurationValue;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.ModifiedBy = this.ModifiedBy;
				to.ModifiedDatetime = this.ModifiedDatetime;
			}

			public bool IsSame(TBL_Configuration x)
			{
				return(
					this.ID == x.ID &&
					this.ConfigurationName == x.ConfigurationName &&
					this.ConfigurationValue == x.ConfigurationValue &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.ModifiedBy == x.ModifiedBy &&
					this.ModifiedDatetime == x.ModifiedDatetime
				);
			}

			public static TBL_Configuration ReadRow(DataRow row)
			{
				TBL_Configuration record = new TBL_Configuration();
				record.ID = get_int_value(row["ID"]);
				record.ConfigurationName = get_string_value(row["ConfigurationName"]);
				record.ConfigurationValue = get_string_value(row["ConfigurationValue"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.ModifiedBy = get_int_value(row["ModifiedBy"]);
				record.ModifiedDatetime = get_DateTime_value(row["ModifiedDatetime"]);
				return record;
			}

			public static List<TBL_Configuration> ReadTable(DataTable dt)
			{
				List<TBL_Configuration> records = new List<TBL_Configuration>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_Configuration
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_Configuration(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_Configuration data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, ConfigurationName, ConfigurationValue, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime
					from Configuration
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "Configuration.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "Configuration.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_Configuration.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Configuration.ID, Configuration.ConfigurationName, Configuration.ConfigurationValue, Configuration.CreatedBy, Configuration.CreatedDatetime, Configuration.ModifiedBy, Configuration.ModifiedDatetime
					from Configuration
					where Configuration.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "Configuration.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, ConfigurationName, ConfigurationValue, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime
					from Configuration
					", ref dt);
                if (!_ok) m_db.LastError = "Configuration.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "Configuration.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Configuration.ID, Configuration.ConfigurationName, Configuration.ConfigurationValue, Configuration.CreatedBy, Configuration.CreatedDatetime, Configuration.ModifiedBy, Configuration.ModifiedDatetime
					from Configuration
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "Configuration.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Configuration.ID, Configuration.ConfigurationName, Configuration.ConfigurationValue, Configuration.CreatedBy, Configuration.CreatedDatetime, Configuration.ModifiedBy, Configuration.ModifiedDatetime
					from Configuration
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "Configuration.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				string ConfigurationName,
				string ConfigurationValue,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDatetime
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into Configuration(
						ConfigurationName,
						ConfigurationValue,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime
						)
					values(
						@ConfigurationName,
						@ConfigurationValue,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime
						)
					", ConfigurationName, ConfigurationValue, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime);
                if (!_ok) m_db.LastError = "Configuration.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				string ConfigurationName,
				string ConfigurationValue,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDatetime
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from Configuration where ID=@ID", ref count, ID))
				{
					m_db.LastError = "Configuration.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "Configuration.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update Configuration
					set
						ConfigurationName = @ConfigurationName,
						ConfigurationValue = @ConfigurationValue,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDatetime = @ModifiedDatetime
					where ID=@ID
					",
					ConfigurationName,
					ConfigurationValue,
					CreatedBy,
					CreatedDatetime,
					ModifiedBy,
					ModifiedDatetime,
					ID
				);
                if (!_ok) m_db.LastError = "Configuration.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from Configuration where ID=@ID", ref count, ID))
				{
					m_db.LastError = "Configuration.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "Configuration.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from Configuration where ID=@ID", ID);
                if (!_ok) m_db.LastError = "Configuration.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region CostCentreInvoiceDetails
		//**********************************************************
		//  CostCentreInvoiceDetails
		//**********************************************************
        CMD_CostCentreInvoiceDetails m_CostCentreInvoiceDetails = null;
        public CMD_CostCentreInvoiceDetails CostCentreInvoiceDetails
        {
            get
            {
				if (m_CostCentreInvoiceDetails == null)
					m_CostCentreInvoiceDetails = new CMD_CostCentreInvoiceDetails(this);
				return m_CostCentreInvoiceDetails;
			}
        }

		[Serializable]
		public class TBL_CostCentreInvoiceDetails
		{
			public int ID { get; set; }
			public int CostCentreID { get; set; }
			public string InvoiceReceiptAddress { get; set; }
			public string InvoiceReceiptContact { get; set; }
			public string InvoiceReceiptEmail { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public int ModifiedBy { get; set; }
			public DateTime ModifiedDatetime { get; set; }

			public TBL_CostCentreInvoiceDetails()
			{
				this.ID = 0;
				this.CostCentreID = 0;
				this.InvoiceReceiptAddress = "";
				this.InvoiceReceiptContact = "";
				this.InvoiceReceiptEmail = "";
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ModifiedBy = 0;
				this.ModifiedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
			}

			public TBL_CostCentreInvoiceDetails(int ID, int CostCentreID, string InvoiceReceiptAddress, string InvoiceReceiptContact, string InvoiceReceiptEmail, int CreatedBy, DateTime CreatedDatetime, int ModifiedBy, DateTime ModifiedDatetime)
			{
				this.ID = ID;
				this.CostCentreID = CostCentreID;
				this.InvoiceReceiptAddress = InvoiceReceiptAddress;
				this.InvoiceReceiptContact = InvoiceReceiptContact;
				this.InvoiceReceiptEmail = InvoiceReceiptEmail;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.ModifiedBy = ModifiedBy;
				this.ModifiedDatetime = ModifiedDatetime;
			}

			public void CopyTo(ref TBL_CostCentreInvoiceDetails to)
			{
				to.ID = this.ID;
				to.CostCentreID = this.CostCentreID;
				to.InvoiceReceiptAddress = this.InvoiceReceiptAddress;
				to.InvoiceReceiptContact = this.InvoiceReceiptContact;
				to.InvoiceReceiptEmail = this.InvoiceReceiptEmail;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.ModifiedBy = this.ModifiedBy;
				to.ModifiedDatetime = this.ModifiedDatetime;
			}

			public bool IsSame(TBL_CostCentreInvoiceDetails x)
			{
				return(
					this.ID == x.ID &&
					this.CostCentreID == x.CostCentreID &&
					this.InvoiceReceiptAddress == x.InvoiceReceiptAddress &&
					this.InvoiceReceiptContact == x.InvoiceReceiptContact &&
					this.InvoiceReceiptEmail == x.InvoiceReceiptEmail &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.ModifiedBy == x.ModifiedBy &&
					this.ModifiedDatetime == x.ModifiedDatetime
				);
			}

			public static TBL_CostCentreInvoiceDetails ReadRow(DataRow row)
			{
				TBL_CostCentreInvoiceDetails record = new TBL_CostCentreInvoiceDetails();
				record.ID = get_int_value(row["ID"]);
				record.CostCentreID = get_int_value(row["CostCentreID"]);
				record.InvoiceReceiptAddress = get_string_value(row["InvoiceReceiptAddress"]);
				record.InvoiceReceiptContact = get_string_value(row["InvoiceReceiptContact"]);
				record.InvoiceReceiptEmail = get_string_value(row["InvoiceReceiptEmail"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.ModifiedBy = get_int_value(row["ModifiedBy"]);
				record.ModifiedDatetime = get_DateTime_value(row["ModifiedDatetime"]);
				return record;
			}

			public static List<TBL_CostCentreInvoiceDetails> ReadTable(DataTable dt)
			{
				List<TBL_CostCentreInvoiceDetails> records = new List<TBL_CostCentreInvoiceDetails>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_CostCentreInvoiceDetails
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_CostCentreInvoiceDetails(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_CostCentreInvoiceDetails data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, CostCentreID, InvoiceReceiptAddress, InvoiceReceiptContact, InvoiceReceiptEmail, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime
					from CostCentreInvoiceDetails
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "CostCentreInvoiceDetails.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "CostCentreInvoiceDetails.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_CostCentreInvoiceDetails.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select CostCentreInvoiceDetails.ID, CostCentreInvoiceDetails.CostCentreID, CostCentreInvoiceDetails.InvoiceReceiptAddress, CostCentreInvoiceDetails.InvoiceReceiptContact, CostCentreInvoiceDetails.InvoiceReceiptEmail, CostCentreInvoiceDetails.CreatedBy, CostCentreInvoiceDetails.CreatedDatetime, CostCentreInvoiceDetails.ModifiedBy, CostCentreInvoiceDetails.ModifiedDatetime
					from CostCentreInvoiceDetails
					where CostCentreInvoiceDetails.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "CostCentreInvoiceDetails.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, CostCentreID, InvoiceReceiptAddress, InvoiceReceiptContact, InvoiceReceiptEmail, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime
					from CostCentreInvoiceDetails
					", ref dt);
                if (!_ok) m_db.LastError = "CostCentreInvoiceDetails.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "CostCentreInvoiceDetails.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select CostCentreInvoiceDetails.ID, CostCentreInvoiceDetails.CostCentreID, CostCentreInvoiceDetails.InvoiceReceiptAddress, CostCentreInvoiceDetails.InvoiceReceiptContact, CostCentreInvoiceDetails.InvoiceReceiptEmail, CostCentreInvoiceDetails.CreatedBy, CostCentreInvoiceDetails.CreatedDatetime, CostCentreInvoiceDetails.ModifiedBy, CostCentreInvoiceDetails.ModifiedDatetime
					from CostCentreInvoiceDetails
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "CostCentreInvoiceDetails.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select CostCentreInvoiceDetails.ID, CostCentreInvoiceDetails.CostCentreID, CostCentreInvoiceDetails.InvoiceReceiptAddress, CostCentreInvoiceDetails.InvoiceReceiptContact, CostCentreInvoiceDetails.InvoiceReceiptEmail, CostCentreInvoiceDetails.CreatedBy, CostCentreInvoiceDetails.CreatedDatetime, CostCentreInvoiceDetails.ModifiedBy, CostCentreInvoiceDetails.ModifiedDatetime
					from CostCentreInvoiceDetails
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "CostCentreInvoiceDetails.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int CostCentreID,
				string InvoiceReceiptAddress,
				string InvoiceReceiptContact,
				string InvoiceReceiptEmail,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDatetime
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into CostCentreInvoiceDetails(
						CostCentreID,
						InvoiceReceiptAddress,
						InvoiceReceiptContact,
						InvoiceReceiptEmail,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime
						)
					values(
						@CostCentreID,
						@InvoiceReceiptAddress,
						@InvoiceReceiptContact,
						@InvoiceReceiptEmail,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime
						)
					", CostCentreID, InvoiceReceiptAddress, InvoiceReceiptContact, InvoiceReceiptEmail, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime);
                if (!_ok) m_db.LastError = "CostCentreInvoiceDetails.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				int CostCentreID,
				string InvoiceReceiptAddress,
				string InvoiceReceiptContact,
				string InvoiceReceiptEmail,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDatetime
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from CostCentreInvoiceDetails where ID=@ID", ref count, ID))
				{
					m_db.LastError = "CostCentreInvoiceDetails.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "CostCentreInvoiceDetails.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update CostCentreInvoiceDetails
					set
						CostCentreID = @CostCentreID,
						InvoiceReceiptAddress = @InvoiceReceiptAddress,
						InvoiceReceiptContact = @InvoiceReceiptContact,
						InvoiceReceiptEmail = @InvoiceReceiptEmail,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDatetime = @ModifiedDatetime
					where ID=@ID
					",
					CostCentreID,
					InvoiceReceiptAddress,
					InvoiceReceiptContact,
					InvoiceReceiptEmail,
					CreatedBy,
					CreatedDatetime,
					ModifiedBy,
					ModifiedDatetime,
					ID
				);
                if (!_ok) m_db.LastError = "CostCentreInvoiceDetails.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from CostCentreInvoiceDetails where ID=@ID", ref count, ID))
				{
					m_db.LastError = "CostCentreInvoiceDetails.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "CostCentreInvoiceDetails.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from CostCentreInvoiceDetails where ID=@ID", ID);
                if (!_ok) m_db.LastError = "CostCentreInvoiceDetails.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region CostCentresInBU
		//**********************************************************
		//  CostCentresInBU
		//**********************************************************
        CMD_CostCentresInBU m_CostCentresInBU = null;
        public CMD_CostCentresInBU CostCentresInBU
        {
            get
            {
				if (m_CostCentresInBU == null)
					m_CostCentresInBU = new CMD_CostCentresInBU(this);
				return m_CostCentresInBU;
			}
        }

		[Serializable]
		public class TBL_CostCentresInBU
		{
			public int ID { get; set; }
			public int BUID { get; set; }
			public string CostCentreIDName { get; set; }
			public string CostCentreName { get; set; }
			public int CostCentreStatus { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public int ModifiedBy { get; set; }
			public DateTime ModifiedDateTime { get; set; }

			public TBL_CostCentresInBU()
			{
				this.ID = 0;
				this.BUID = 0;
				this.CostCentreIDName = "";
				this.CostCentreName = "";
				this.CostCentreStatus = 0;
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ModifiedBy = 0;
				this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
			}

			public TBL_CostCentresInBU(int ID, int BUID, string CostCentreIDName, string CostCentreName, int CostCentreStatus, int CreatedBy, DateTime CreatedDatetime, int ModifiedBy, DateTime ModifiedDateTime)
			{
				this.ID = ID;
				this.BUID = BUID;
				this.CostCentreIDName = CostCentreIDName;
				this.CostCentreName = CostCentreName;
				this.CostCentreStatus = CostCentreStatus;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.ModifiedBy = ModifiedBy;
				this.ModifiedDateTime = ModifiedDateTime;
			}

			public void CopyTo(ref TBL_CostCentresInBU to)
			{
				to.ID = this.ID;
				to.BUID = this.BUID;
				to.CostCentreIDName = this.CostCentreIDName;
				to.CostCentreName = this.CostCentreName;
				to.CostCentreStatus = this.CostCentreStatus;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.ModifiedBy = this.ModifiedBy;
				to.ModifiedDateTime = this.ModifiedDateTime;
			}

			public bool IsSame(TBL_CostCentresInBU x)
			{
				return(
					this.ID == x.ID &&
					this.BUID == x.BUID &&
					this.CostCentreIDName == x.CostCentreIDName &&
					this.CostCentreName == x.CostCentreName &&
					this.CostCentreStatus == x.CostCentreStatus &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.ModifiedBy == x.ModifiedBy &&
					this.ModifiedDateTime == x.ModifiedDateTime
				);
			}

			public static TBL_CostCentresInBU ReadRow(DataRow row)
			{
				TBL_CostCentresInBU record = new TBL_CostCentresInBU();
				record.ID = get_int_value(row["ID"]);
				record.BUID = get_int_value(row["BUID"]);
				record.CostCentreIDName = get_string_value(row["CostCentreIDName"]);
				record.CostCentreName = get_string_value(row["CostCentreName"]);
				record.CostCentreStatus = get_int_value(row["CostCentreStatus"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.ModifiedBy = get_int_value(row["ModifiedBy"]);
				record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
				return record;
			}

			public static List<TBL_CostCentresInBU> ReadTable(DataTable dt)
			{
				List<TBL_CostCentresInBU> records = new List<TBL_CostCentresInBU>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_CostCentresInBU
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_CostCentresInBU(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_CostCentresInBU data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, BUID, CostCentreIDName, CostCentreName, CostCentreStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from CostCentresInBU
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "CostCentresInBU.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "CostCentresInBU.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_CostCentresInBU.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select CostCentresInBU.ID, CostCentresInBU.BUID, CostCentresInBU.CostCentreIDName, CostCentresInBU.CostCentreName, CostCentresInBU.CostCentreStatus, CostCentresInBU.CreatedBy, CostCentresInBU.CreatedDatetime, CostCentresInBU.ModifiedBy, CostCentresInBU.ModifiedDateTime
					from CostCentresInBU
					where CostCentresInBU.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "CostCentresInBU.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, BUID, CostCentreIDName, CostCentreName, CostCentreStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from CostCentresInBU
					", ref dt);
                if (!_ok) m_db.LastError = "CostCentresInBU.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "CostCentresInBU.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select CostCentresInBU.ID, CostCentresInBU.BUID, CostCentresInBU.CostCentreIDName, CostCentresInBU.CostCentreName, CostCentresInBU.CostCentreStatus, CostCentresInBU.CreatedBy, CostCentresInBU.CreatedDatetime, CostCentresInBU.ModifiedBy, CostCentresInBU.ModifiedDateTime
					from CostCentresInBU
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "CostCentresInBU.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select CostCentresInBU.ID, CostCentresInBU.BUID, CostCentresInBU.CostCentreIDName, CostCentresInBU.CostCentreName, CostCentresInBU.CostCentreStatus, CostCentresInBU.CreatedBy, CostCentresInBU.CreatedDatetime, CostCentresInBU.ModifiedBy, CostCentresInBU.ModifiedDateTime
					from CostCentresInBU
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "CostCentresInBU.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int BUID,
				string CostCentreIDName,
				string CostCentreName,
				int CostCentreStatus,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into CostCentresInBU(
						BUID,
						CostCentreIDName,
						CostCentreName,
						CostCentreStatus,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@BUID,
						@CostCentreIDName,
						@CostCentreName,
						@CostCentreStatus,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", BUID, CostCentreIDName, CostCentreName, CostCentreStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);
                if (!_ok) m_db.LastError = "CostCentresInBU.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				int BUID,
				string CostCentreIDName,
				string CostCentreName,
				int CostCentreStatus,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from CostCentresInBU where ID=@ID", ref count, ID))
				{
					m_db.LastError = "CostCentresInBU.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "CostCentresInBU.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update CostCentresInBU
					set
						BUID = @BUID,
						CostCentreIDName = @CostCentreIDName,
						CostCentreName = @CostCentreName,
						CostCentreStatus = @CostCentreStatus,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime
					where ID=@ID
					",
					BUID,
					CostCentreIDName,
					CostCentreName,
					CostCentreStatus,
					CreatedBy,
					CreatedDatetime,
					ModifiedBy,
					ModifiedDateTime,
					ID
				);
                if (!_ok) m_db.LastError = "CostCentresInBU.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from CostCentresInBU where ID=@ID", ref count, ID))
				{
					m_db.LastError = "CostCentresInBU.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "CostCentresInBU.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from CostCentresInBU where ID=@ID", ID);
                if (!_ok) m_db.LastError = "CostCentresInBU.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region GroupMember
		//**********************************************************
		//  GroupMember
		//**********************************************************
        CMD_GroupMember m_GroupMember = null;
        public CMD_GroupMember GroupMember
        {
            get
            {
				if (m_GroupMember == null)
					m_GroupMember = new CMD_GroupMember(this);
				return m_GroupMember;
			}
        }

		[Serializable]
		public class TBL_GroupMember
		{
			public int GroupID { get; set; }
			public string GroupName { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public int ModifiedBy { get; set; }
			public DateTime ModifiedDateTime { get; set; }
			public int GroupStatus { get; set; }

			public TBL_GroupMember()
			{
				this.GroupID = 0;
				this.GroupName = "";
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ModifiedBy = 0;
				this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.GroupStatus = 0;
			}

			public TBL_GroupMember(int GroupID, string GroupName, int CreatedBy, DateTime CreatedDatetime, int ModifiedBy, DateTime ModifiedDateTime, int GroupStatus)
			{
				this.GroupID = GroupID;
				this.GroupName = GroupName;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.ModifiedBy = ModifiedBy;
				this.ModifiedDateTime = ModifiedDateTime;
				this.GroupStatus = GroupStatus;
			}

			public void CopyTo(ref TBL_GroupMember to)
			{
				to.GroupID = this.GroupID;
				to.GroupName = this.GroupName;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.ModifiedBy = this.ModifiedBy;
				to.ModifiedDateTime = this.ModifiedDateTime;
				to.GroupStatus = this.GroupStatus;
			}

			public bool IsSame(TBL_GroupMember x)
			{
				return(
					this.GroupID == x.GroupID &&
					this.GroupName == x.GroupName &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.ModifiedBy == x.ModifiedBy &&
					this.ModifiedDateTime == x.ModifiedDateTime &&
					this.GroupStatus == x.GroupStatus
				);
			}

			public static TBL_GroupMember ReadRow(DataRow row)
			{
				TBL_GroupMember record = new TBL_GroupMember();
				record.GroupID = get_int_value(row["GroupID"]);
				record.GroupName = get_string_value(row["GroupName"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.ModifiedBy = get_int_value(row["ModifiedBy"]);
				record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
				record.GroupStatus = get_int_value(row["GroupStatus"]);
				return record;
			}

			public static List<TBL_GroupMember> ReadTable(DataTable dt)
			{
				List<TBL_GroupMember> records = new List<TBL_GroupMember>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_GroupMember
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_GroupMember(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int GroupID,
				ref TBL_GroupMember data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select GroupID, GroupName, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, GroupStatus
					from GroupMember
					where GroupID=@GroupID
					", ref dt, GroupID))
                {
                    m_db.LastError = "GroupMember.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "GroupMember.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_GroupMember.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int GroupID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select GroupMember.GroupID, GroupMember.GroupName, GroupMember.CreatedBy, GroupMember.CreatedDatetime, GroupMember.ModifiedBy, GroupMember.ModifiedDateTime, GroupMember.GroupStatus
					from GroupMember
					where GroupMember.GroupID=@GroupID
					", ref dt, GroupID);
                if (!_ok) m_db.LastError = "GroupMember.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select GroupID, GroupName, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, GroupStatus
					from GroupMember
					", ref dt);
                if (!_ok) m_db.LastError = "GroupMember.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "GroupMember.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select GroupMember.GroupID, GroupMember.GroupName, GroupMember.CreatedBy, GroupMember.CreatedDatetime, GroupMember.ModifiedBy, GroupMember.ModifiedDateTime, GroupMember.GroupStatus
					from GroupMember
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "GroupMember.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select GroupMember.GroupID, GroupMember.GroupName, GroupMember.CreatedBy, GroupMember.CreatedDatetime, GroupMember.ModifiedBy, GroupMember.ModifiedDateTime, GroupMember.GroupStatus
					from GroupMember
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "GroupMember.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				string GroupName,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime,
				int GroupStatus
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into GroupMember(
						GroupName,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime,
						GroupStatus
						)
					values(
						@GroupName,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime,
						@GroupStatus
						)
					", GroupName, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, GroupStatus);
                if (!_ok) m_db.LastError = "GroupMember.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int GroupID,
				string GroupName,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime,
				int GroupStatus
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from GroupMember where GroupID=@GroupID", ref count, GroupID))
				{
					m_db.LastError = "GroupMember.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "GroupMember.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update GroupMember
					set
						GroupName = @GroupName,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime,
						GroupStatus = @GroupStatus
					where GroupID=@GroupID
					",
					GroupName,
					CreatedBy,
					CreatedDatetime,
					ModifiedBy,
					ModifiedDateTime,
					GroupStatus,
					GroupID
				);
                if (!_ok) m_db.LastError = "GroupMember.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int GroupID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from GroupMember where GroupID=@GroupID", ref count, GroupID))
				{
					m_db.LastError = "GroupMember.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "GroupMember.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from GroupMember where GroupID=@GroupID", GroupID);
                if (!_ok) m_db.LastError = "GroupMember.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region GroupMemberInResourcePermission
		//**********************************************************
		//  GroupMemberInResourcePermission
		//**********************************************************
        CMD_GroupMemberInResourcePermission m_GroupMemberInResourcePermission = null;
        public CMD_GroupMemberInResourcePermission GroupMemberInResourcePermission
        {
            get
            {
				if (m_GroupMemberInResourcePermission == null)
					m_GroupMemberInResourcePermission = new CMD_GroupMemberInResourcePermission(this);
				return m_GroupMemberInResourcePermission;
			}
        }

		[Serializable]
		public class TBL_GroupMemberInResourcePermission
		{
			public int GroupMemberID { get; set; }
			public int ResourceID { get; set; }
			public int Create0 { get; set; }
			public int Read0 { get; set; }
			public int Update0 { get; set; }
			public int Delete0 { get; set; }
			public int Status { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public int ModifiedBy { get; set; }
			public DateTime ModifiedDateTime { get; set; }

			public TBL_GroupMemberInResourcePermission()
			{
				this.GroupMemberID = 0;
				this.ResourceID = 0;
				this.Create0 = 0;
				this.Read0 = 0;
				this.Update0 = 0;
				this.Delete0 = 0;
				this.Status = 0;
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ModifiedBy = 0;
				this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
			}

			public TBL_GroupMemberInResourcePermission(int GroupMemberID, int ResourceID, int Create0, int Read0, int Update0, int Delete0, int Status, int CreatedBy, DateTime CreatedDatetime, int ModifiedBy, DateTime ModifiedDateTime)
			{
				this.GroupMemberID = GroupMemberID;
				this.ResourceID = ResourceID;
				this.Create0 = Create0;
				this.Read0 = Read0;
				this.Update0 = Update0;
				this.Delete0 = Delete0;
				this.Status = Status;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.ModifiedBy = ModifiedBy;
				this.ModifiedDateTime = ModifiedDateTime;
			}

			public void CopyTo(ref TBL_GroupMemberInResourcePermission to)
			{
				to.GroupMemberID = this.GroupMemberID;
				to.ResourceID = this.ResourceID;
				to.Create0 = this.Create0;
				to.Read0 = this.Read0;
				to.Update0 = this.Update0;
				to.Delete0 = this.Delete0;
				to.Status = this.Status;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.ModifiedBy = this.ModifiedBy;
				to.ModifiedDateTime = this.ModifiedDateTime;
			}

			public bool IsSame(TBL_GroupMemberInResourcePermission x)
			{
				return(
					this.GroupMemberID == x.GroupMemberID &&
					this.ResourceID == x.ResourceID &&
					this.Create0 == x.Create0 &&
					this.Read0 == x.Read0 &&
					this.Update0 == x.Update0 &&
					this.Delete0 == x.Delete0 &&
					this.Status == x.Status &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.ModifiedBy == x.ModifiedBy &&
					this.ModifiedDateTime == x.ModifiedDateTime
				);
			}

			public static TBL_GroupMemberInResourcePermission ReadRow(DataRow row)
			{
				TBL_GroupMemberInResourcePermission record = new TBL_GroupMemberInResourcePermission();
				record.GroupMemberID = get_int_value(row["GroupMemberID"]);
				record.ResourceID = get_int_value(row["ResourceID"]);
				record.Create0 = get_int_value(row["Create0"]);
				record.Read0 = get_int_value(row["Read0"]);
				record.Update0 = get_int_value(row["Update0"]);
				record.Delete0 = get_int_value(row["Delete0"]);
				record.Status = get_int_value(row["Status"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.ModifiedBy = get_int_value(row["ModifiedBy"]);
				record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
				return record;
			}

			public static List<TBL_GroupMemberInResourcePermission> ReadTable(DataTable dt)
			{
				List<TBL_GroupMemberInResourcePermission> records = new List<TBL_GroupMemberInResourcePermission>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_GroupMemberInResourcePermission
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_GroupMemberInResourcePermission(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int GroupMemberID,
				int ResourceID,
				ref TBL_GroupMemberInResourcePermission data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select GroupMemberID, ResourceID, Create0, Read0, Update0, Delete0, Status, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from GroupMemberInResourcePermission
					where GroupMemberID=@GroupMemberID and ResourceID=@ResourceID
					", ref dt, GroupMemberID, ResourceID))
                {
                    m_db.LastError = "GroupMemberInResourcePermission.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "GroupMemberInResourcePermission.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_GroupMemberInResourcePermission.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int GroupMemberID,
				int ResourceID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select GroupMemberInResourcePermission.GroupMemberID, GroupMemberInResourcePermission.ResourceID, GroupMemberInResourcePermission.Create0, GroupMemberInResourcePermission.Read0, GroupMemberInResourcePermission.Update0, GroupMemberInResourcePermission.Delete0, GroupMemberInResourcePermission.Status, GroupMemberInResourcePermission.CreatedBy, GroupMemberInResourcePermission.CreatedDatetime, GroupMemberInResourcePermission.ModifiedBy, GroupMemberInResourcePermission.ModifiedDateTime
					from GroupMemberInResourcePermission
					where GroupMemberInResourcePermission.GroupMemberID=@GroupMemberID and GroupMemberInResourcePermission.ResourceID=@ResourceID
					", ref dt, GroupMemberID, ResourceID);
                if (!_ok) m_db.LastError = "GroupMemberInResourcePermission.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select GroupMemberID, ResourceID, Create0, Read0, Update0, Delete0, Status, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from GroupMemberInResourcePermission
					", ref dt);
                if (!_ok) m_db.LastError = "GroupMemberInResourcePermission.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "GroupMemberInResourcePermission.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select GroupMemberInResourcePermission.GroupMemberID, GroupMemberInResourcePermission.ResourceID, GroupMemberInResourcePermission.Create0, GroupMemberInResourcePermission.Read0, GroupMemberInResourcePermission.Update0, GroupMemberInResourcePermission.Delete0, GroupMemberInResourcePermission.Status, GroupMemberInResourcePermission.CreatedBy, GroupMemberInResourcePermission.CreatedDatetime, GroupMemberInResourcePermission.ModifiedBy, GroupMemberInResourcePermission.ModifiedDateTime
					from GroupMemberInResourcePermission
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "GroupMemberInResourcePermission.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select GroupMemberInResourcePermission.GroupMemberID, GroupMemberInResourcePermission.ResourceID, GroupMemberInResourcePermission.Create0, GroupMemberInResourcePermission.Read0, GroupMemberInResourcePermission.Update0, GroupMemberInResourcePermission.Delete0, GroupMemberInResourcePermission.Status, GroupMemberInResourcePermission.CreatedBy, GroupMemberInResourcePermission.CreatedDatetime, GroupMemberInResourcePermission.ModifiedBy, GroupMemberInResourcePermission.ModifiedDateTime
					from GroupMemberInResourcePermission
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "GroupMemberInResourcePermission.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int GroupMemberID,
				int ResourceID,
				int Create0,
				int Read0,
				int Update0,
				int Delete0,
				int Status,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime
			)
			{            
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from GroupMemberInResourcePermission where GroupMemberID=@GroupMemberID and ResourceID=@ResourceID", ref count, GroupMemberID, ResourceID))
				{
					m_db.LastError = "GroupMemberInResourcePermission.insert error.\r\n" + m_db.LastError;
					return false;
				}
				if (count > 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "GroupMemberInResourcePermission.insert error. ID duplicate";
					return false;
				}

				bool _ok = m_db.ExecSqlCmd(@"
					insert into GroupMemberInResourcePermission(
						GroupMemberID,
						ResourceID,
						Create0,
						Read0,
						Update0,
						Delete0,
						Status,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@GroupMemberID,
						@ResourceID,
						@Create0,
						@Read0,
						@Update0,
						@Delete0,
						@Status,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", GroupMemberID, ResourceID, Create0, Read0, Update0, Delete0, Status, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);
                if (!_ok) m_db.LastError = "GroupMemberInResourcePermission.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int _old_GroupMemberID,
				int _old_ResourceID,
				int _new_GroupMemberID,
				int _new_ResourceID,
				int Create0,
				int Read0,
				int Update0,
				int Delete0,
				int Status,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from GroupMemberInResourcePermission where GroupMemberID=@_old_GroupMemberID and ResourceID=@_old_ResourceID", ref count, _old_GroupMemberID, _old_ResourceID))
				{
					m_db.LastError = "GroupMemberInResourcePermission.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "GroupMemberInResourcePermission.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update GroupMemberInResourcePermission
					set
						GroupMemberID = @_new_GroupMemberID,
						ResourceID = @_new_ResourceID,
						Create0 = @Create0,
						Read0 = @Read0,
						Update0 = @Update0,
						Delete0 = @Delete0,
						Status = @Status,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime
					where GroupMemberID=@_old_GroupMemberID and ResourceID=@_old_ResourceID
					",
					_new_GroupMemberID,
					_new_ResourceID,
					Create0,
					Read0,
					Update0,
					Delete0,
					Status,
					CreatedBy,
					CreatedDatetime,
					ModifiedBy,
					ModifiedDateTime,
					_old_GroupMemberID,
					_old_ResourceID
				);
                if (!_ok) m_db.LastError = "GroupMemberInResourcePermission.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int GroupMemberID,
				int ResourceID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from GroupMemberInResourcePermission where GroupMemberID=@GroupMemberID and ResourceID=@ResourceID", ref count, GroupMemberID, ResourceID))
				{
					m_db.LastError = "GroupMemberInResourcePermission.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "GroupMemberInResourcePermission.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from GroupMemberInResourcePermission where GroupMemberID=@GroupMemberID and ResourceID=@ResourceID", GroupMemberID, ResourceID);
                if (!_ok) m_db.LastError = "GroupMemberInResourcePermission.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region MasterProfile
		//**********************************************************
		//  MasterProfile
		//**********************************************************
        CMD_MasterProfile m_MasterProfile = null;
        public CMD_MasterProfile MasterProfile
        {
            get
            {
				if (m_MasterProfile == null)
					m_MasterProfile = new CMD_MasterProfile(this);
				return m_MasterProfile;
			}
        }

		[Serializable]
		public class TBL_MasterProfile
		{
			public int ID { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public int ModifiedBy { get; set; }
			public DateTime ModifiedDatetime { get; set; }

			public TBL_MasterProfile()
			{
				this.ID = 0;
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ModifiedBy = 0;
				this.ModifiedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
			}

			public TBL_MasterProfile(int ID, int CreatedBy, DateTime CreatedDatetime, int ModifiedBy, DateTime ModifiedDatetime)
			{
				this.ID = ID;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.ModifiedBy = ModifiedBy;
				this.ModifiedDatetime = ModifiedDatetime;
			}

			public void CopyTo(ref TBL_MasterProfile to)
			{
				to.ID = this.ID;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.ModifiedBy = this.ModifiedBy;
				to.ModifiedDatetime = this.ModifiedDatetime;
			}

			public bool IsSame(TBL_MasterProfile x)
			{
				return(
					this.ID == x.ID &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.ModifiedBy == x.ModifiedBy &&
					this.ModifiedDatetime == x.ModifiedDatetime
				);
			}

			public static TBL_MasterProfile ReadRow(DataRow row)
			{
				TBL_MasterProfile record = new TBL_MasterProfile();
				record.ID = get_int_value(row["ID"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.ModifiedBy = get_int_value(row["ModifiedBy"]);
				record.ModifiedDatetime = get_DateTime_value(row["ModifiedDatetime"]);
				return record;
			}

			public static List<TBL_MasterProfile> ReadTable(DataTable dt)
			{
				List<TBL_MasterProfile> records = new List<TBL_MasterProfile>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_MasterProfile
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_MasterProfile(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_MasterProfile data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime
					from MasterProfile
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "MasterProfile.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "MasterProfile.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_MasterProfile.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select MasterProfile.ID, MasterProfile.CreatedBy, MasterProfile.CreatedDatetime, MasterProfile.ModifiedBy, MasterProfile.ModifiedDatetime
					from MasterProfile
					where MasterProfile.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "MasterProfile.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime
					from MasterProfile
					", ref dt);
                if (!_ok) m_db.LastError = "MasterProfile.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "MasterProfile.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select MasterProfile.ID, MasterProfile.CreatedBy, MasterProfile.CreatedDatetime, MasterProfile.ModifiedBy, MasterProfile.ModifiedDatetime
					from MasterProfile
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "MasterProfile.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select MasterProfile.ID, MasterProfile.CreatedBy, MasterProfile.CreatedDatetime, MasterProfile.ModifiedBy, MasterProfile.ModifiedDatetime
					from MasterProfile
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "MasterProfile.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDatetime
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into MasterProfile(
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime
						)
					values(
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime
						)
					", CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime);
                if (!_ok) m_db.LastError = "MasterProfile.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDatetime
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from MasterProfile where ID=@ID", ref count, ID))
				{
					m_db.LastError = "MasterProfile.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "MasterProfile.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update MasterProfile
					set
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDatetime = @ModifiedDatetime
					where ID=@ID
					",
					CreatedBy,
					CreatedDatetime,
					ModifiedBy,
					ModifiedDatetime,
					ID
				);
                if (!_ok) m_db.LastError = "MasterProfile.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from MasterProfile where ID=@ID", ref count, ID))
				{
					m_db.LastError = "MasterProfile.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "MasterProfile.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from MasterProfile where ID=@ID", ID);
                if (!_ok) m_db.LastError = "MasterProfile.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region Notice
		//**********************************************************
		//  Notice
		//**********************************************************
        CMD_Notice m_Notice = null;
        public CMD_Notice Notice
        {
            get
            {
				if (m_Notice == null)
					m_Notice = new CMD_Notice(this);
				return m_Notice;
			}
        }

		[Serializable]
		public class TBL_Notice
		{
			public int ID { get; set; }
			public string Subject { get; set; }
			public string Body0 { get; set; }
			public DateTime PublishDate { get; set; }
			public DateTime ExpiredDate { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public int ModifiedBy { get; set; }
			public DateTime ModifiedDatetime { get; set; }

			public TBL_Notice()
			{
				this.ID = 0;
				this.Subject = "";
				this.Body0 = "";
				this.PublishDate = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ExpiredDate = Convert.ToDateTime("1900-01-01 00:00:00");
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ModifiedBy = 0;
				this.ModifiedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
			}

			public TBL_Notice(int ID, string Subject, string Body0, DateTime PublishDate, DateTime ExpiredDate, int CreatedBy, DateTime CreatedDatetime, int ModifiedBy, DateTime ModifiedDatetime)
			{
				this.ID = ID;
				this.Subject = Subject;
				this.Body0 = Body0;
				this.PublishDate = PublishDate;
				this.ExpiredDate = ExpiredDate;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.ModifiedBy = ModifiedBy;
				this.ModifiedDatetime = ModifiedDatetime;
			}

			public void CopyTo(ref TBL_Notice to)
			{
				to.ID = this.ID;
				to.Subject = this.Subject;
				to.Body0 = this.Body0;
				to.PublishDate = this.PublishDate;
				to.ExpiredDate = this.ExpiredDate;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.ModifiedBy = this.ModifiedBy;
				to.ModifiedDatetime = this.ModifiedDatetime;
			}

			public bool IsSame(TBL_Notice x)
			{
				return(
					this.ID == x.ID &&
					this.Subject == x.Subject &&
					this.Body0 == x.Body0 &&
					this.PublishDate == x.PublishDate &&
					this.ExpiredDate == x.ExpiredDate &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.ModifiedBy == x.ModifiedBy &&
					this.ModifiedDatetime == x.ModifiedDatetime
				);
			}

			public static TBL_Notice ReadRow(DataRow row)
			{
				TBL_Notice record = new TBL_Notice();
				record.ID = get_int_value(row["ID"]);
				record.Subject = get_string_value(row["Subject"]);
				record.Body0 = get_string_value(row["Body0"]);
				record.PublishDate = get_DateTime_value(row["PublishDate"]);
				record.ExpiredDate = get_DateTime_value(row["ExpiredDate"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.ModifiedBy = get_int_value(row["ModifiedBy"]);
				record.ModifiedDatetime = get_DateTime_value(row["ModifiedDatetime"]);
				return record;
			}

			public static List<TBL_Notice> ReadTable(DataTable dt)
			{
				List<TBL_Notice> records = new List<TBL_Notice>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_Notice
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_Notice(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_Notice data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, Subject, Body0, PublishDate, ExpiredDate, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime
					from Notice
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "Notice.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "Notice.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_Notice.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Notice.ID, Notice.Subject, Notice.Body0, Notice.PublishDate, Notice.ExpiredDate, Notice.CreatedBy, Notice.CreatedDatetime, Notice.ModifiedBy, Notice.ModifiedDatetime
					from Notice
					where Notice.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "Notice.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, Subject, Body0, PublishDate, ExpiredDate, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime
					from Notice
					", ref dt);
                if (!_ok) m_db.LastError = "Notice.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "Notice.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Notice.ID, Notice.Subject, Notice.Body0, Notice.PublishDate, Notice.ExpiredDate, Notice.CreatedBy, Notice.CreatedDatetime, Notice.ModifiedBy, Notice.ModifiedDatetime
					from Notice
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "Notice.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Notice.ID, Notice.Subject, Notice.Body0, Notice.PublishDate, Notice.ExpiredDate, Notice.CreatedBy, Notice.CreatedDatetime, Notice.ModifiedBy, Notice.ModifiedDatetime
					from Notice
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "Notice.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				string Subject,
				string Body0,
				DateTime PublishDate,
				DateTime ExpiredDate,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDatetime
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into Notice(
						Subject,
						Body0,
						PublishDate,
						ExpiredDate,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime
						)
					values(
						@Subject,
						@Body0,
						@PublishDate,
						@ExpiredDate,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime
						)
					", Subject, Body0, PublishDate, ExpiredDate, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime);
                if (!_ok) m_db.LastError = "Notice.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				string Subject,
				string Body0,
				DateTime PublishDate,
				DateTime ExpiredDate,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDatetime
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from Notice where ID=@ID", ref count, ID))
				{
					m_db.LastError = "Notice.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "Notice.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update Notice
					set
						Subject = @Subject,
						Body0 = @Body0,
						PublishDate = @PublishDate,
						ExpiredDate = @ExpiredDate,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDatetime = @ModifiedDatetime
					where ID=@ID
					",
					Subject,
					Body0,
					PublishDate,
					ExpiredDate,
					CreatedBy,
					CreatedDatetime,
					ModifiedBy,
					ModifiedDatetime,
					ID
				);
                if (!_ok) m_db.LastError = "Notice.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from Notice where ID=@ID", ref count, ID))
				{
					m_db.LastError = "Notice.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "Notice.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from Notice where ID=@ID", ID);
                if (!_ok) m_db.LastError = "Notice.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region Agency
		//**********************************************************
		//  Agency
		//**********************************************************
        CMD_Agency m_Agency = null;
        public CMD_Agency Agency
        {
            get
            {
				if (m_Agency == null)
					m_Agency = new CMD_Agency(this);
				return m_Agency;
			}
        }

		[Serializable]
		public class TBL_Agency
		{
			public int ID { get; set; }
			public string AgencyIDName { get; set; }
			public string AgencyName { get; set; }
			public int IsMinistry { get; set; }
			public int AgencyStatus { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public int ModifiedBy { get; set; }
			public DateTime ModifiedDateTime { get; set; }

			public TBL_Agency()
			{
				this.ID = 0;
				this.AgencyIDName = "";
				this.AgencyName = "";
				this.IsMinistry = 0;
				this.AgencyStatus = 0;
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ModifiedBy = 0;
				this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
			}

			public TBL_Agency(int ID, string AgencyIDName, string AgencyName, int IsMinistry, int AgencyStatus, int CreatedBy, DateTime CreatedDatetime, int ModifiedBy, DateTime ModifiedDateTime)
			{
				this.ID = ID;
				this.AgencyIDName = AgencyIDName;
				this.AgencyName = AgencyName;
				this.IsMinistry = IsMinistry;
				this.AgencyStatus = AgencyStatus;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.ModifiedBy = ModifiedBy;
				this.ModifiedDateTime = ModifiedDateTime;
			}

			public void CopyTo(ref TBL_Agency to)
			{
				to.ID = this.ID;
				to.AgencyIDName = this.AgencyIDName;
				to.AgencyName = this.AgencyName;
				to.IsMinistry = this.IsMinistry;
				to.AgencyStatus = this.AgencyStatus;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.ModifiedBy = this.ModifiedBy;
				to.ModifiedDateTime = this.ModifiedDateTime;
			}

			public bool IsSame(TBL_Agency x)
			{
				return(
					this.ID == x.ID &&
					this.AgencyIDName == x.AgencyIDName &&
					this.AgencyName == x.AgencyName &&
					this.IsMinistry == x.IsMinistry &&
					this.AgencyStatus == x.AgencyStatus &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.ModifiedBy == x.ModifiedBy &&
					this.ModifiedDateTime == x.ModifiedDateTime
				);
			}

			public static TBL_Agency ReadRow(DataRow row)
			{
				TBL_Agency record = new TBL_Agency();
				record.ID = get_int_value(row["ID"]);
				record.AgencyIDName = get_string_value(row["AgencyIDName"]);
				record.AgencyName = get_string_value(row["AgencyName"]);
				record.IsMinistry = get_int_value(row["IsMinistry"]);
				record.AgencyStatus = get_int_value(row["AgencyStatus"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.ModifiedBy = get_int_value(row["ModifiedBy"]);
				record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
				return record;
			}

			public static List<TBL_Agency> ReadTable(DataTable dt)
			{
				List<TBL_Agency> records = new List<TBL_Agency>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_Agency
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_Agency(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_Agency data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, AgencyIDName, AgencyName, IsMinistry, AgencyStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from Agency
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "Agency.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "Agency.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_Agency.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Agency.ID, Agency.AgencyIDName, Agency.AgencyName, Agency.IsMinistry, Agency.AgencyStatus, Agency.CreatedBy, Agency.CreatedDatetime, Agency.ModifiedBy, Agency.ModifiedDateTime
					from Agency
					where Agency.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "Agency.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, AgencyIDName, AgencyName, IsMinistry, AgencyStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from Agency
					", ref dt);
                if (!_ok) m_db.LastError = "Agency.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "Agency.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Agency.ID, Agency.AgencyIDName, Agency.AgencyName, Agency.IsMinistry, Agency.AgencyStatus, Agency.CreatedBy, Agency.CreatedDatetime, Agency.ModifiedBy, Agency.ModifiedDateTime
					from Agency
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "Agency.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Agency.ID, Agency.AgencyIDName, Agency.AgencyName, Agency.IsMinistry, Agency.AgencyStatus, Agency.CreatedBy, Agency.CreatedDatetime, Agency.ModifiedBy, Agency.ModifiedDateTime
					from Agency
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "Agency.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				string AgencyIDName,
				string AgencyName,
				int IsMinistry,
				int AgencyStatus,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into Agency(
						AgencyIDName,
						AgencyName,
						IsMinistry,
						AgencyStatus,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@AgencyIDName,
						@AgencyName,
						@IsMinistry,
						@AgencyStatus,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", AgencyIDName, AgencyName, IsMinistry, AgencyStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);
                if (!_ok) m_db.LastError = "Agency.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				string AgencyIDName,
				string AgencyName,
				int IsMinistry,
				int AgencyStatus,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from Agency where ID=@ID", ref count, ID))
				{
					m_db.LastError = "Agency.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "Agency.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update Agency
					set
						AgencyIDName = @AgencyIDName,
						AgencyName = @AgencyName,
						IsMinistry = @IsMinistry,
						AgencyStatus = @AgencyStatus,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime
					where ID=@ID
					",
					AgencyIDName,
					AgencyName,
					IsMinistry,
					AgencyStatus,
					CreatedBy,
					CreatedDatetime,
					ModifiedBy,
					ModifiedDateTime,
					ID
				);
                if (!_ok) m_db.LastError = "Agency.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from Agency where ID=@ID", ref count, ID))
				{
					m_db.LastError = "Agency.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "Agency.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from Agency where ID=@ID", ID);
                if (!_ok) m_db.LastError = "Agency.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region Reports
		//**********************************************************
		//  Reports
		//**********************************************************
        CMD_Reports m_Reports = null;
        public CMD_Reports Reports
        {
            get
            {
				if (m_Reports == null)
					m_Reports = new CMD_Reports(this);
				return m_Reports;
			}
        }

		[Serializable]
		public class TBL_Reports
		{
			public int ID { get; set; }
			public int ReportID { get; set; }
			public DateTime ReportingPeriod { get; set; }
			public object ReportData { get; set; }
			public int ReportForBU { get; set; }
			public int ReportStatus { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public int ModifiedBy { get; set; }
			public DateTime ModifiedDatetime { get; set; }
			public int ReportForUserTypeID { get; set; }
			public int ReportForCostCentre { get; set; }

			public TBL_Reports()
			{
				this.ID = 0;
				this.ReportID = 0;
				this.ReportingPeriod = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ReportData = null;
				this.ReportForBU = 0;
				this.ReportStatus = 0;
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ModifiedBy = 0;
				this.ModifiedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ReportForUserTypeID = 0;
				this.ReportForCostCentre = 0;
			}

			public TBL_Reports(int ID, int ReportID, DateTime ReportingPeriod, object ReportData, int ReportForBU, int ReportStatus, int CreatedBy, DateTime CreatedDatetime, int ModifiedBy, DateTime ModifiedDatetime, int ReportForUserTypeID, int ReportForCostCentre)
			{
				this.ID = ID;
				this.ReportID = ReportID;
				this.ReportingPeriod = ReportingPeriod;
				this.ReportData = ReportData;
				this.ReportForBU = ReportForBU;
				this.ReportStatus = ReportStatus;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.ModifiedBy = ModifiedBy;
				this.ModifiedDatetime = ModifiedDatetime;
				this.ReportForUserTypeID = ReportForUserTypeID;
				this.ReportForCostCentre = ReportForCostCentre;
			}

			public void CopyTo(ref TBL_Reports to)
			{
				to.ID = this.ID;
				to.ReportID = this.ReportID;
				to.ReportingPeriod = this.ReportingPeriod;
				to.ReportData = this.ReportData;
				to.ReportForBU = this.ReportForBU;
				to.ReportStatus = this.ReportStatus;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.ModifiedBy = this.ModifiedBy;
				to.ModifiedDatetime = this.ModifiedDatetime;
				to.ReportForUserTypeID = this.ReportForUserTypeID;
				to.ReportForCostCentre = this.ReportForCostCentre;
			}

			public bool IsSame(TBL_Reports x)
			{
				return(
					this.ID == x.ID &&
					this.ReportID == x.ReportID &&
					this.ReportingPeriod == x.ReportingPeriod &&
					this.ReportData == x.ReportData &&
					this.ReportForBU == x.ReportForBU &&
					this.ReportStatus == x.ReportStatus &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.ModifiedBy == x.ModifiedBy &&
					this.ModifiedDatetime == x.ModifiedDatetime &&
					this.ReportForUserTypeID == x.ReportForUserTypeID &&
					this.ReportForCostCentre == x.ReportForCostCentre
				);
			}

			public static TBL_Reports ReadRow(DataRow row)
			{
				TBL_Reports record = new TBL_Reports();
				record.ID = get_int_value(row["ID"]);
				record.ReportID = get_int_value(row["ReportID"]);
				record.ReportingPeriod = get_DateTime_value(row["ReportingPeriod"]);
				record.ReportData = get_object_value(row["ReportData"]);
				record.ReportForBU = get_int_value(row["ReportForBU"]);
				record.ReportStatus = get_int_value(row["ReportStatus"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.ModifiedBy = get_int_value(row["ModifiedBy"]);
				record.ModifiedDatetime = get_DateTime_value(row["ModifiedDatetime"]);
				record.ReportForUserTypeID = get_int_value(row["ReportForUserTypeID"]);
				record.ReportForCostCentre = get_int_value(row["ReportForCostCentre"]);
				return record;
			}

			public static List<TBL_Reports> ReadTable(DataTable dt)
			{
				List<TBL_Reports> records = new List<TBL_Reports>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_Reports
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_Reports(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_Reports data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, ReportID, ReportingPeriod, ReportData, ReportForBU, ReportStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime, ReportForUserTypeID, ReportForCostCentre
					from Reports
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "Reports.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "Reports.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_Reports.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Reports.ID, Reports.ReportID, Reports.ReportingPeriod, Reports.ReportData, Reports.ReportForBU, Reports.ReportStatus, Reports.CreatedBy, Reports.CreatedDatetime, Reports.ModifiedBy, Reports.ModifiedDatetime, Reports.ReportForUserTypeID, Reports.ReportForCostCentre
					from Reports
					where Reports.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "Reports.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, ReportID, ReportingPeriod, ReportData, ReportForBU, ReportStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime, ReportForUserTypeID, ReportForCostCentre
					from Reports
					", ref dt);
                if (!_ok) m_db.LastError = "Reports.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "Reports.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Reports.ID, Reports.ReportID, Reports.ReportingPeriod, Reports.ReportData, Reports.ReportForBU, Reports.ReportStatus, Reports.CreatedBy, Reports.CreatedDatetime, Reports.ModifiedBy, Reports.ModifiedDatetime, Reports.ReportForUserTypeID, Reports.ReportForCostCentre
					from Reports
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "Reports.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select Reports.ID, Reports.ReportID, Reports.ReportingPeriod, Reports.ReportData, Reports.ReportForBU, Reports.ReportStatus, Reports.CreatedBy, Reports.CreatedDatetime, Reports.ModifiedBy, Reports.ModifiedDatetime, Reports.ReportForUserTypeID, Reports.ReportForCostCentre
					from Reports
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "Reports.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int ReportID,
				DateTime ReportingPeriod,
				object ReportData,
				int ReportForBU,
				int ReportStatus,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDatetime,
				int ReportForUserTypeID,
				int ReportForCostCentre
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into Reports(
						ReportID,
						ReportingPeriod,
						ReportData,
						ReportForBU,
						ReportStatus,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime,
						ReportForUserTypeID,
						ReportForCostCentre
						)
					values(
						@ReportID,
						@ReportingPeriod,
						@ReportData,
						@ReportForBU,
						@ReportStatus,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime,
						@ReportForUserTypeID,
						@ReportForCostCentre
						)
					", ReportID, ReportingPeriod, ReportData, ReportForBU, ReportStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime, ReportForUserTypeID, ReportForCostCentre);
                if (!_ok) m_db.LastError = "Reports.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				int ReportID,
				DateTime ReportingPeriod,
				object ReportData,
				int ReportForBU,
				int ReportStatus,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDatetime,
				int ReportForUserTypeID,
				int ReportForCostCentre
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from Reports where ID=@ID", ref count, ID))
				{
					m_db.LastError = "Reports.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "Reports.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update Reports
					set
						ReportID = @ReportID,
						ReportingPeriod = @ReportingPeriod,
						ReportData = @ReportData,
						ReportForBU = @ReportForBU,
						ReportStatus = @ReportStatus,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDatetime = @ModifiedDatetime,
						ReportForUserTypeID = @ReportForUserTypeID,
						ReportForCostCentre = @ReportForCostCentre
					where ID=@ID
					",
					ReportID,
					ReportingPeriod,
					ReportData,
					ReportForBU,
					ReportStatus,
					CreatedBy,
					CreatedDatetime,
					ModifiedBy,
					ModifiedDatetime,
					ReportForUserTypeID,
					ReportForCostCentre,
					ID
				);
                if (!_ok) m_db.LastError = "Reports.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from Reports where ID=@ID", ref count, ID))
				{
					m_db.LastError = "Reports.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "Reports.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from Reports where ID=@ID", ID);
                if (!_ok) m_db.LastError = "Reports.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region ReportStoreProcedures
		//**********************************************************
		//  ReportStoreProcedures
		//**********************************************************
        CMD_ReportStoreProcedures m_ReportStoreProcedures = null;
        public CMD_ReportStoreProcedures ReportStoreProcedures
        {
            get
            {
				if (m_ReportStoreProcedures == null)
					m_ReportStoreProcedures = new CMD_ReportStoreProcedures(this);
				return m_ReportStoreProcedures;
			}
        }

		[Serializable]
		public class TBL_ReportStoreProcedures
		{
			public int ID { get; set; }
			public int ReportID { get; set; }
			public string StoreProcName { get; set; }
			public string ReportDatasetName { get; set; }
			public int SRType { get; set; }

			public TBL_ReportStoreProcedures()
			{
				this.ID = 0;
				this.ReportID = 0;
				this.StoreProcName = "";
				this.ReportDatasetName = "";
				this.SRType = 0;
			}

			public TBL_ReportStoreProcedures(int ID, int ReportID, string StoreProcName, string ReportDatasetName, int SRType)
			{
				this.ID = ID;
				this.ReportID = ReportID;
				this.StoreProcName = StoreProcName;
				this.ReportDatasetName = ReportDatasetName;
				this.SRType = SRType;
			}

			public void CopyTo(ref TBL_ReportStoreProcedures to)
			{
				to.ID = this.ID;
				to.ReportID = this.ReportID;
				to.StoreProcName = this.StoreProcName;
				to.ReportDatasetName = this.ReportDatasetName;
				to.SRType = this.SRType;
			}

			public bool IsSame(TBL_ReportStoreProcedures x)
			{
				return(
					this.ID == x.ID &&
					this.ReportID == x.ReportID &&
					this.StoreProcName == x.StoreProcName &&
					this.ReportDatasetName == x.ReportDatasetName &&
					this.SRType == x.SRType
				);
			}

			public static TBL_ReportStoreProcedures ReadRow(DataRow row)
			{
				TBL_ReportStoreProcedures record = new TBL_ReportStoreProcedures();
				record.ID = get_int_value(row["ID"]);
				record.ReportID = get_int_value(row["ReportID"]);
				record.StoreProcName = get_string_value(row["StoreProcName"]);
				record.ReportDatasetName = get_string_value(row["ReportDatasetName"]);
				record.SRType = get_int_value(row["SRType"]);
				return record;
			}

			public static List<TBL_ReportStoreProcedures> ReadTable(DataTable dt)
			{
				List<TBL_ReportStoreProcedures> records = new List<TBL_ReportStoreProcedures>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_ReportStoreProcedures
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_ReportStoreProcedures(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_ReportStoreProcedures data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, ReportID, StoreProcName, ReportDatasetName, SRType
					from ReportStoreProcedures
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "ReportStoreProcedures.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "ReportStoreProcedures.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_ReportStoreProcedures.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ReportStoreProcedures.ID, ReportStoreProcedures.ReportID, ReportStoreProcedures.StoreProcName, ReportStoreProcedures.ReportDatasetName, ReportStoreProcedures.SRType
					from ReportStoreProcedures
					where ReportStoreProcedures.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "ReportStoreProcedures.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, ReportID, StoreProcName, ReportDatasetName, SRType
					from ReportStoreProcedures
					", ref dt);
                if (!_ok) m_db.LastError = "ReportStoreProcedures.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "ReportStoreProcedures.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ReportStoreProcedures.ID, ReportStoreProcedures.ReportID, ReportStoreProcedures.StoreProcName, ReportStoreProcedures.ReportDatasetName, ReportStoreProcedures.SRType
					from ReportStoreProcedures
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "ReportStoreProcedures.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ReportStoreProcedures.ID, ReportStoreProcedures.ReportID, ReportStoreProcedures.StoreProcName, ReportStoreProcedures.ReportDatasetName, ReportStoreProcedures.SRType
					from ReportStoreProcedures
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "ReportStoreProcedures.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int ReportID,
				string StoreProcName,
				string ReportDatasetName,
				int SRType
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into ReportStoreProcedures(
						ReportID,
						StoreProcName,
						ReportDatasetName,
						SRType
						)
					values(
						@ReportID,
						@StoreProcName,
						@ReportDatasetName,
						@SRType
						)
					", ReportID, StoreProcName, ReportDatasetName, SRType);
                if (!_ok) m_db.LastError = "ReportStoreProcedures.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				int ReportID,
				string StoreProcName,
				string ReportDatasetName,
				int SRType
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ReportStoreProcedures where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ReportStoreProcedures.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ReportStoreProcedures.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update ReportStoreProcedures
					set
						ReportID = @ReportID,
						StoreProcName = @StoreProcName,
						ReportDatasetName = @ReportDatasetName,
						SRType = @SRType
					where ID=@ID
					",
					ReportID,
					StoreProcName,
					ReportDatasetName,
					SRType,
					ID
				);
                if (!_ok) m_db.LastError = "ReportStoreProcedures.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ReportStoreProcedures where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ReportStoreProcedures.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ReportStoreProcedures.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from ReportStoreProcedures where ID=@ID", ID);
                if (!_ok) m_db.LastError = "ReportStoreProcedures.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region ReportTemplates
		//**********************************************************
		//  ReportTemplates
		//**********************************************************
        CMD_ReportTemplates m_ReportTemplates = null;
        public CMD_ReportTemplates ReportTemplates
        {
            get
            {
				if (m_ReportTemplates == null)
					m_ReportTemplates = new CMD_ReportTemplates(this);
				return m_ReportTemplates;
			}
        }

		[Serializable]
		public class TBL_ReportTemplates
		{
			public int ID { get; set; }
			public string ReportTitle { get; set; }
			public string ReportContentType { get; set; }
			public string ReportName { get; set; }
			public int ReportForBU { get; set; }
			public int ReportTypeID { get; set; }

			public TBL_ReportTemplates()
			{
				this.ID = 0;
				this.ReportTitle = "";
				this.ReportContentType = "";
				this.ReportName = "";
				this.ReportForBU = 0;
				this.ReportTypeID = 0;
			}

			public TBL_ReportTemplates(int ID, string ReportTitle, string ReportContentType, string ReportName, int ReportForBU, int ReportTypeID)
			{
				this.ID = ID;
				this.ReportTitle = ReportTitle;
				this.ReportContentType = ReportContentType;
				this.ReportName = ReportName;
				this.ReportForBU = ReportForBU;
				this.ReportTypeID = ReportTypeID;
			}

			public void CopyTo(ref TBL_ReportTemplates to)
			{
				to.ID = this.ID;
				to.ReportTitle = this.ReportTitle;
				to.ReportContentType = this.ReportContentType;
				to.ReportName = this.ReportName;
				to.ReportForBU = this.ReportForBU;
				to.ReportTypeID = this.ReportTypeID;
			}

			public bool IsSame(TBL_ReportTemplates x)
			{
				return(
					this.ID == x.ID &&
					this.ReportTitle == x.ReportTitle &&
					this.ReportContentType == x.ReportContentType &&
					this.ReportName == x.ReportName &&
					this.ReportForBU == x.ReportForBU &&
					this.ReportTypeID == x.ReportTypeID
				);
			}

			public static TBL_ReportTemplates ReadRow(DataRow row)
			{
				TBL_ReportTemplates record = new TBL_ReportTemplates();
				record.ID = get_int_value(row["ID"]);
				record.ReportTitle = get_string_value(row["ReportTitle"]);
				record.ReportContentType = get_string_value(row["ReportContentType"]);
				record.ReportName = get_string_value(row["ReportName"]);
				record.ReportForBU = get_int_value(row["ReportForBU"]);
				record.ReportTypeID = get_int_value(row["ReportTypeID"]);
				return record;
			}

			public static List<TBL_ReportTemplates> ReadTable(DataTable dt)
			{
				List<TBL_ReportTemplates> records = new List<TBL_ReportTemplates>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_ReportTemplates
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_ReportTemplates(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_ReportTemplates data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, ReportTitle, ReportContentType, ReportName, ReportForBU, ReportTypeID
					from ReportTemplates
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "ReportTemplates.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "ReportTemplates.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_ReportTemplates.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ReportTemplates.ID, ReportTemplates.ReportTitle, ReportTemplates.ReportContentType, ReportTemplates.ReportName, ReportTemplates.ReportForBU, ReportTemplates.ReportTypeID
					from ReportTemplates
					where ReportTemplates.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "ReportTemplates.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, ReportTitle, ReportContentType, ReportName, ReportForBU, ReportTypeID
					from ReportTemplates
					", ref dt);
                if (!_ok) m_db.LastError = "ReportTemplates.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "ReportTemplates.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ReportTemplates.ID, ReportTemplates.ReportTitle, ReportTemplates.ReportContentType, ReportTemplates.ReportName, ReportTemplates.ReportForBU, ReportTemplates.ReportTypeID
					from ReportTemplates
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "ReportTemplates.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ReportTemplates.ID, ReportTemplates.ReportTitle, ReportTemplates.ReportContentType, ReportTemplates.ReportName, ReportTemplates.ReportForBU, ReportTemplates.ReportTypeID
					from ReportTemplates
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "ReportTemplates.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				string ReportTitle,
				string ReportContentType,
				string ReportName,
				int ReportForBU,
				int ReportTypeID
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into ReportTemplates(
						ReportTitle,
						ReportContentType,
						ReportName,
						ReportForBU,
						ReportTypeID
						)
					values(
						@ReportTitle,
						@ReportContentType,
						@ReportName,
						@ReportForBU,
						@ReportTypeID
						)
					", ReportTitle, ReportContentType, ReportName, ReportForBU, ReportTypeID);
                if (!_ok) m_db.LastError = "ReportTemplates.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				string ReportTitle,
				string ReportContentType,
				string ReportName,
				int ReportForBU,
				int ReportTypeID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ReportTemplates where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ReportTemplates.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ReportTemplates.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update ReportTemplates
					set
						ReportTitle = @ReportTitle,
						ReportContentType = @ReportContentType,
						ReportName = @ReportName,
						ReportForBU = @ReportForBU,
						ReportTypeID = @ReportTypeID
					where ID=@ID
					",
					ReportTitle,
					ReportContentType,
					ReportName,
					ReportForBU,
					ReportTypeID,
					ID
				);
                if (!_ok) m_db.LastError = "ReportTemplates.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ReportTemplates where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ReportTemplates.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ReportTemplates.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from ReportTemplates where ID=@ID", ID);
                if (!_ok) m_db.LastError = "ReportTemplates.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region ReportType
		//**********************************************************
		//  ReportType
		//**********************************************************
        CMD_ReportType m_ReportType = null;
        public CMD_ReportType ReportType
        {
            get
            {
				if (m_ReportType == null)
					m_ReportType = new CMD_ReportType(this);
				return m_ReportType;
			}
        }

		[Serializable]
		public class TBL_ReportType
		{
			public int ID { get; set; }
			public string ReportTypeName { get; set; }

			public TBL_ReportType()
			{
				this.ID = 0;
				this.ReportTypeName = "";
			}

			public TBL_ReportType(int ID, string ReportTypeName)
			{
				this.ID = ID;
				this.ReportTypeName = ReportTypeName;
			}

			public void CopyTo(ref TBL_ReportType to)
			{
				to.ID = this.ID;
				to.ReportTypeName = this.ReportTypeName;
			}

			public bool IsSame(TBL_ReportType x)
			{
				return(
					this.ID == x.ID &&
					this.ReportTypeName == x.ReportTypeName
				);
			}

			public static TBL_ReportType ReadRow(DataRow row)
			{
				TBL_ReportType record = new TBL_ReportType();
				record.ID = get_int_value(row["ID"]);
				record.ReportTypeName = get_string_value(row["ReportTypeName"]);
				return record;
			}

			public static List<TBL_ReportType> ReadTable(DataTable dt)
			{
				List<TBL_ReportType> records = new List<TBL_ReportType>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_ReportType
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_ReportType(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_ReportType data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, ReportTypeName
					from ReportType
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "ReportType.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "ReportType.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_ReportType.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ReportType.ID, ReportType.ReportTypeName
					from ReportType
					where ReportType.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "ReportType.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, ReportTypeName
					from ReportType
					", ref dt);
                if (!_ok) m_db.LastError = "ReportType.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "ReportType.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ReportType.ID, ReportType.ReportTypeName
					from ReportType
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "ReportType.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ReportType.ID, ReportType.ReportTypeName
					from ReportType
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "ReportType.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				string ReportTypeName
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into ReportType(
						ReportTypeName
						)
					values(
						@ReportTypeName
						)
					", ReportTypeName);
                if (!_ok) m_db.LastError = "ReportType.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				string ReportTypeName
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ReportType where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ReportType.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ReportType.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update ReportType
					set
						ReportTypeName = @ReportTypeName
					where ID=@ID
					",
					ReportTypeName,
					ID
				);
                if (!_ok) m_db.LastError = "ReportType.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ReportType where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ReportType.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ReportType.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from ReportType where ID=@ID", ID);
                if (!_ok) m_db.LastError = "ReportType.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region ResourceManagerInCostCentre
		//**********************************************************
		//  ResourceManagerInCostCentre
		//**********************************************************
        CMD_ResourceManagerInCostCentre m_ResourceManagerInCostCentre = null;
        public CMD_ResourceManagerInCostCentre ResourceManagerInCostCentre
        {
            get
            {
				if (m_ResourceManagerInCostCentre == null)
					m_ResourceManagerInCostCentre = new CMD_ResourceManagerInCostCentre(this);
				return m_ResourceManagerInCostCentre;
			}
        }

		[Serializable]
		public class TBL_ResourceManagerInCostCentre
		{
			public int ID { get; set; }
			public int CostCentreID { get; set; }
			public string RmName { get; set; }
			public int Status { get; set; }

			public TBL_ResourceManagerInCostCentre()
			{
				this.ID = 0;
				this.CostCentreID = 0;
				this.RmName = "";
				this.Status = 0;
			}

			public TBL_ResourceManagerInCostCentre(int ID, int CostCentreID, string RmName, int Status)
			{
				this.ID = ID;
				this.CostCentreID = CostCentreID;
				this.RmName = RmName;
				this.Status = Status;
			}

			public void CopyTo(ref TBL_ResourceManagerInCostCentre to)
			{
				to.ID = this.ID;
				to.CostCentreID = this.CostCentreID;
				to.RmName = this.RmName;
				to.Status = this.Status;
			}

			public bool IsSame(TBL_ResourceManagerInCostCentre x)
			{
				return(
					this.ID == x.ID &&
					this.CostCentreID == x.CostCentreID &&
					this.RmName == x.RmName &&
					this.Status == x.Status
				);
			}

			public static TBL_ResourceManagerInCostCentre ReadRow(DataRow row)
			{
				TBL_ResourceManagerInCostCentre record = new TBL_ResourceManagerInCostCentre();
				record.ID = get_int_value(row["ID"]);
				record.CostCentreID = get_int_value(row["CostCentreID"]);
				record.RmName = get_string_value(row["RmName"]);
				record.Status = get_int_value(row["Status"]);
				return record;
			}

			public static List<TBL_ResourceManagerInCostCentre> ReadTable(DataTable dt)
			{
				List<TBL_ResourceManagerInCostCentre> records = new List<TBL_ResourceManagerInCostCentre>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_ResourceManagerInCostCentre
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_ResourceManagerInCostCentre(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}



			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, CostCentreID, RmName, Status
					from ResourceManagerInCostCentre
					", ref dt);
                if (!_ok) m_db.LastError = "ResourceManagerInCostCentre.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "ResourceManagerInCostCentre.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ResourceManagerInCostCentre.ID, ResourceManagerInCostCentre.CostCentreID, ResourceManagerInCostCentre.RmName, ResourceManagerInCostCentre.Status
					from ResourceManagerInCostCentre
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "ResourceManagerInCostCentre.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ResourceManagerInCostCentre.ID, ResourceManagerInCostCentre.CostCentreID, ResourceManagerInCostCentre.RmName, ResourceManagerInCostCentre.Status
					from ResourceManagerInCostCentre
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "ResourceManagerInCostCentre.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int ID,
				int CostCentreID,
				string RmName,
				int Status
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into ResourceManagerInCostCentre(
						ID,
						CostCentreID,
						RmName,
						Status
						)
					values(
						@ID,
						@CostCentreID,
						@RmName,
						@Status
						)
					", ID, CostCentreID, RmName, Status);
                if (!_ok) m_db.LastError = "ResourceManagerInCostCentre.insert error.\r\n" + m_db.LastError;
                return _ok;
			}


        
		}

		#endregion

		#region ResourceMenu
		//**********************************************************
		//  ResourceMenu
		//**********************************************************
        CMD_ResourceMenu m_ResourceMenu = null;
        public CMD_ResourceMenu ResourceMenu
        {
            get
            {
				if (m_ResourceMenu == null)
					m_ResourceMenu = new CMD_ResourceMenu(this);
				return m_ResourceMenu;
			}
        }

		[Serializable]
		public class TBL_ResourceMenu
		{
			public int ID { get; set; }
			public int Parent { get; set; }
			public string ResourceName { get; set; }
			public string PageURL { get; set; }
			public int Status { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public int ModifiedBy { get; set; }
			public DateTime ModifiedDateTime { get; set; }
			public int PageOrder { get; set; }

			public TBL_ResourceMenu()
			{
				this.ID = 0;
				this.Parent = 0;
				this.ResourceName = "";
				this.PageURL = "";
				this.Status = 0;
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ModifiedBy = 0;
				this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.PageOrder = 0;
			}

			public TBL_ResourceMenu(int ID, int Parent, string ResourceName, string PageURL, int Status, int CreatedBy, DateTime CreatedDatetime, int ModifiedBy, DateTime ModifiedDateTime, int PageOrder)
			{
				this.ID = ID;
				this.Parent = Parent;
				this.ResourceName = ResourceName;
				this.PageURL = PageURL;
				this.Status = Status;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.ModifiedBy = ModifiedBy;
				this.ModifiedDateTime = ModifiedDateTime;
				this.PageOrder = PageOrder;
			}

			public void CopyTo(ref TBL_ResourceMenu to)
			{
				to.ID = this.ID;
				to.Parent = this.Parent;
				to.ResourceName = this.ResourceName;
				to.PageURL = this.PageURL;
				to.Status = this.Status;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.ModifiedBy = this.ModifiedBy;
				to.ModifiedDateTime = this.ModifiedDateTime;
				to.PageOrder = this.PageOrder;
			}

			public bool IsSame(TBL_ResourceMenu x)
			{
				return(
					this.ID == x.ID &&
					this.Parent == x.Parent &&
					this.ResourceName == x.ResourceName &&
					this.PageURL == x.PageURL &&
					this.Status == x.Status &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.ModifiedBy == x.ModifiedBy &&
					this.ModifiedDateTime == x.ModifiedDateTime &&
					this.PageOrder == x.PageOrder
				);
			}

			public static TBL_ResourceMenu ReadRow(DataRow row)
			{
				TBL_ResourceMenu record = new TBL_ResourceMenu();
				record.ID = get_int_value(row["ID"]);
				record.Parent = get_int_value(row["Parent"]);
				record.ResourceName = get_string_value(row["ResourceName"]);
				record.PageURL = get_string_value(row["PageURL"]);
				record.Status = get_int_value(row["Status"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.ModifiedBy = get_int_value(row["ModifiedBy"]);
				record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
				record.PageOrder = get_int_value(row["PageOrder"]);
				return record;
			}

			public static List<TBL_ResourceMenu> ReadTable(DataTable dt)
			{
				List<TBL_ResourceMenu> records = new List<TBL_ResourceMenu>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_ResourceMenu
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_ResourceMenu(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_ResourceMenu data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, Parent, ResourceName, PageURL, Status, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, PageOrder
					from ResourceMenu
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "ResourceMenu.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "ResourceMenu.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_ResourceMenu.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ResourceMenu.ID, ResourceMenu.Parent, ResourceMenu.ResourceName, ResourceMenu.PageURL, ResourceMenu.Status, ResourceMenu.CreatedBy, ResourceMenu.CreatedDatetime, ResourceMenu.ModifiedBy, ResourceMenu.ModifiedDateTime, ResourceMenu.PageOrder
					from ResourceMenu
					where ResourceMenu.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "ResourceMenu.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, Parent, ResourceName, PageURL, Status, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, PageOrder
					from ResourceMenu
					", ref dt);
                if (!_ok) m_db.LastError = "ResourceMenu.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "ResourceMenu.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ResourceMenu.ID, ResourceMenu.Parent, ResourceMenu.ResourceName, ResourceMenu.PageURL, ResourceMenu.Status, ResourceMenu.CreatedBy, ResourceMenu.CreatedDatetime, ResourceMenu.ModifiedBy, ResourceMenu.ModifiedDateTime, ResourceMenu.PageOrder
					from ResourceMenu
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "ResourceMenu.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ResourceMenu.ID, ResourceMenu.Parent, ResourceMenu.ResourceName, ResourceMenu.PageURL, ResourceMenu.Status, ResourceMenu.CreatedBy, ResourceMenu.CreatedDatetime, ResourceMenu.ModifiedBy, ResourceMenu.ModifiedDateTime, ResourceMenu.PageOrder
					from ResourceMenu
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "ResourceMenu.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int Parent,
				string ResourceName,
				string PageURL,
				int Status,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime,
				int PageOrder
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into ResourceMenu(
						Parent,
						ResourceName,
						PageURL,
						Status,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime,
						PageOrder
						)
					values(
						@Parent,
						@ResourceName,
						@PageURL,
						@Status,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime,
						@PageOrder
						)
					", Parent, ResourceName, PageURL, Status, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, PageOrder);
                if (!_ok) m_db.LastError = "ResourceMenu.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				int Parent,
				string ResourceName,
				string PageURL,
				int Status,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime,
				int PageOrder
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ResourceMenu where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ResourceMenu.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ResourceMenu.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update ResourceMenu
					set
						Parent = @Parent,
						ResourceName = @ResourceName,
						PageURL = @PageURL,
						Status = @Status,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime,
						PageOrder = @PageOrder
					where ID=@ID
					",
					Parent,
					ResourceName,
					PageURL,
					Status,
					CreatedBy,
					CreatedDatetime,
					ModifiedBy,
					ModifiedDateTime,
					PageOrder,
					ID
				);
                if (!_ok) m_db.LastError = "ResourceMenu.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ResourceMenu where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ResourceMenu.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ResourceMenu.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from ResourceMenu where ID=@ID", ID);
                if (!_ok) m_db.LastError = "ResourceMenu.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region ServiceRequest
		//**********************************************************
		//  ServiceRequest
		//**********************************************************
        CMD_ServiceRequest m_ServiceRequest = null;
        public CMD_ServiceRequest ServiceRequest
        {
            get
            {
				if (m_ServiceRequest == null)
					m_ServiceRequest = new CMD_ServiceRequest(this);
				return m_ServiceRequest;
			}
        }

		[Serializable]
		public class TBL_ServiceRequest
		{
			public int ID { get; set; }
			public string SRUniqueID { get; set; }
			public int SRType { get; set; }
			public int BUID { get; set; }
			public int CostCentreID { get; set; }
			public int SRStatus { get; set; }
			public string Remarks { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public DateTime AckDatetime { get; set; }
			public int AckBy { get; set; }

			public TBL_ServiceRequest()
			{
				this.ID = 0;
				this.SRUniqueID = "";
				this.SRType = 0;
				this.BUID = 0;
				this.CostCentreID = 0;
				this.SRStatus = 0;
				this.Remarks = "";
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.AckDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.AckBy = 0;
			}

			public TBL_ServiceRequest(int ID, string SRUniqueID, int SRType, int BUID, int CostCentreID, int SRStatus, string Remarks, int CreatedBy, DateTime CreatedDatetime, DateTime AckDatetime, int AckBy)
			{
				this.ID = ID;
				this.SRUniqueID = SRUniqueID;
				this.SRType = SRType;
				this.BUID = BUID;
				this.CostCentreID = CostCentreID;
				this.SRStatus = SRStatus;
				this.Remarks = Remarks;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.AckDatetime = AckDatetime;
				this.AckBy = AckBy;
			}

			public void CopyTo(ref TBL_ServiceRequest to)
			{
				to.ID = this.ID;
				to.SRUniqueID = this.SRUniqueID;
				to.SRType = this.SRType;
				to.BUID = this.BUID;
				to.CostCentreID = this.CostCentreID;
				to.SRStatus = this.SRStatus;
				to.Remarks = this.Remarks;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.AckDatetime = this.AckDatetime;
				to.AckBy = this.AckBy;
			}

			public bool IsSame(TBL_ServiceRequest x)
			{
				return(
					this.ID == x.ID &&
					this.SRUniqueID == x.SRUniqueID &&
					this.SRType == x.SRType &&
					this.BUID == x.BUID &&
					this.CostCentreID == x.CostCentreID &&
					this.SRStatus == x.SRStatus &&
					this.Remarks == x.Remarks &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.AckDatetime == x.AckDatetime &&
					this.AckBy == x.AckBy
				);
			}

			public static TBL_ServiceRequest ReadRow(DataRow row)
			{
				TBL_ServiceRequest record = new TBL_ServiceRequest();
				record.ID = get_int_value(row["ID"]);
				record.SRUniqueID = get_string_value(row["SRUniqueID"]);
				record.SRType = get_int_value(row["SRType"]);
				record.BUID = get_int_value(row["BUID"]);
				record.CostCentreID = get_int_value(row["CostCentreID"]);
				record.SRStatus = get_int_value(row["SRStatus"]);
				record.Remarks = get_string_value(row["Remarks"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.AckDatetime = get_DateTime_value(row["AckDatetime"]);
				record.AckBy = get_int_value(row["AckBy"]);
				return record;
			}

			public static List<TBL_ServiceRequest> ReadTable(DataTable dt)
			{
				List<TBL_ServiceRequest> records = new List<TBL_ServiceRequest>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_ServiceRequest
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_ServiceRequest(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_ServiceRequest data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, SRUniqueID, SRType, BUID, CostCentreID, SRStatus, Remarks, CreatedBy, CreatedDatetime, AckDatetime, AckBy
					from ServiceRequest
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "ServiceRequest.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "ServiceRequest.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_ServiceRequest.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ServiceRequest.ID, ServiceRequest.SRUniqueID, ServiceRequest.SRType, ServiceRequest.BUID, ServiceRequest.CostCentreID, ServiceRequest.SRStatus, ServiceRequest.Remarks, ServiceRequest.CreatedBy, ServiceRequest.CreatedDatetime, ServiceRequest.AckDatetime, ServiceRequest.AckBy
					from ServiceRequest
					where ServiceRequest.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "ServiceRequest.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, SRUniqueID, SRType, BUID, CostCentreID, SRStatus, Remarks, CreatedBy, CreatedDatetime, AckDatetime, AckBy
					from ServiceRequest
					", ref dt);
                if (!_ok) m_db.LastError = "ServiceRequest.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "ServiceRequest.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ServiceRequest.ID, ServiceRequest.SRUniqueID, ServiceRequest.SRType, ServiceRequest.BUID, ServiceRequest.CostCentreID, ServiceRequest.SRStatus, ServiceRequest.Remarks, ServiceRequest.CreatedBy, ServiceRequest.CreatedDatetime, ServiceRequest.AckDatetime, ServiceRequest.AckBy
					from ServiceRequest
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "ServiceRequest.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ServiceRequest.ID, ServiceRequest.SRUniqueID, ServiceRequest.SRType, ServiceRequest.BUID, ServiceRequest.CostCentreID, ServiceRequest.SRStatus, ServiceRequest.Remarks, ServiceRequest.CreatedBy, ServiceRequest.CreatedDatetime, ServiceRequest.AckDatetime, ServiceRequest.AckBy
					from ServiceRequest
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "ServiceRequest.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				string SRUniqueID,
				int SRType,
				int BUID,
				int CostCentreID,
				int SRStatus,
				string Remarks,
				int CreatedBy,
				DateTime CreatedDatetime,
				DateTime AckDatetime,
				int AckBy
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into ServiceRequest(
						SRUniqueID,
						SRType,
						BUID,
						CostCentreID,
						SRStatus,
						Remarks,
						CreatedBy,
						CreatedDatetime,
						AckDatetime,
						AckBy
						)
					values(
						@SRUniqueID,
						@SRType,
						@BUID,
						@CostCentreID,
						@SRStatus,
						@Remarks,
						@CreatedBy,
						@CreatedDatetime,
						@AckDatetime,
						@AckBy
						)
					", SRUniqueID, SRType, BUID, CostCentreID, SRStatus, Remarks, CreatedBy, CreatedDatetime, AckDatetime, AckBy);
                if (!_ok) m_db.LastError = "ServiceRequest.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				string SRUniqueID,
				int SRType,
				int BUID,
				int CostCentreID,
				int SRStatus,
				string Remarks,
				int CreatedBy,
				DateTime CreatedDatetime,
				DateTime AckDatetime,
				int AckBy
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ServiceRequest where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ServiceRequest.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ServiceRequest.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update ServiceRequest
					set
						SRUniqueID = @SRUniqueID,
						SRType = @SRType,
						BUID = @BUID,
						CostCentreID = @CostCentreID,
						SRStatus = @SRStatus,
						Remarks = @Remarks,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						AckDatetime = @AckDatetime,
						AckBy = @AckBy
					where ID=@ID
					",
					SRUniqueID,
					SRType,
					BUID,
					CostCentreID,
					SRStatus,
					Remarks,
					CreatedBy,
					CreatedDatetime,
					AckDatetime,
					AckBy,
					ID
				);
                if (!_ok) m_db.LastError = "ServiceRequest.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ServiceRequest where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ServiceRequest.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ServiceRequest.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from ServiceRequest where ID=@ID", ID);
                if (!_ok) m_db.LastError = "ServiceRequest.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region ServiceRequestStatus
		//**********************************************************
		//  ServiceRequestStatus
		//**********************************************************
        CMD_ServiceRequestStatus m_ServiceRequestStatus = null;
        public CMD_ServiceRequestStatus ServiceRequestStatus
        {
            get
            {
				if (m_ServiceRequestStatus == null)
					m_ServiceRequestStatus = new CMD_ServiceRequestStatus(this);
				return m_ServiceRequestStatus;
			}
        }

		[Serializable]
		public class TBL_ServiceRequestStatus
		{
			public int ID { get; set; }
			public string StatusName { get; set; }

			public TBL_ServiceRequestStatus()
			{
				this.ID = 0;
				this.StatusName = "";
			}

			public TBL_ServiceRequestStatus(int ID, string StatusName)
			{
				this.ID = ID;
				this.StatusName = StatusName;
			}

			public void CopyTo(ref TBL_ServiceRequestStatus to)
			{
				to.ID = this.ID;
				to.StatusName = this.StatusName;
			}

			public bool IsSame(TBL_ServiceRequestStatus x)
			{
				return(
					this.ID == x.ID &&
					this.StatusName == x.StatusName
				);
			}

			public static TBL_ServiceRequestStatus ReadRow(DataRow row)
			{
				TBL_ServiceRequestStatus record = new TBL_ServiceRequestStatus();
				record.ID = get_int_value(row["ID"]);
				record.StatusName = get_string_value(row["StatusName"]);
				return record;
			}

			public static List<TBL_ServiceRequestStatus> ReadTable(DataTable dt)
			{
				List<TBL_ServiceRequestStatus> records = new List<TBL_ServiceRequestStatus>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_ServiceRequestStatus
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_ServiceRequestStatus(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_ServiceRequestStatus data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, StatusName
					from ServiceRequestStatus
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "ServiceRequestStatus.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "ServiceRequestStatus.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_ServiceRequestStatus.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ServiceRequestStatus.ID, ServiceRequestStatus.StatusName
					from ServiceRequestStatus
					where ServiceRequestStatus.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "ServiceRequestStatus.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, StatusName
					from ServiceRequestStatus
					", ref dt);
                if (!_ok) m_db.LastError = "ServiceRequestStatus.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "ServiceRequestStatus.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ServiceRequestStatus.ID, ServiceRequestStatus.StatusName
					from ServiceRequestStatus
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "ServiceRequestStatus.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ServiceRequestStatus.ID, ServiceRequestStatus.StatusName
					from ServiceRequestStatus
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "ServiceRequestStatus.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int ID,
				string StatusName
			)
			{            
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ServiceRequestStatus where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ServiceRequestStatus.insert error.\r\n" + m_db.LastError;
					return false;
				}
				if (count > 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ServiceRequestStatus.insert error. ID duplicate";
					return false;
				}

				bool _ok = m_db.ExecSqlCmd(@"
					insert into ServiceRequestStatus(
						ID,
						StatusName
						)
					values(
						@ID,
						@StatusName
						)
					", ID, StatusName);
                if (!_ok) m_db.LastError = "ServiceRequestStatus.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int _old_ID,
				int _new_ID,
				string StatusName
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ServiceRequestStatus where ID=@_old_ID", ref count, _old_ID))
				{
					m_db.LastError = "ServiceRequestStatus.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ServiceRequestStatus.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update ServiceRequestStatus
					set
						ID = @_new_ID,
						StatusName = @StatusName
					where ID=@_old_ID
					",
					_new_ID,
					StatusName,
					_old_ID
				);
                if (!_ok) m_db.LastError = "ServiceRequestStatus.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ServiceRequestStatus where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ServiceRequestStatus.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ServiceRequestStatus.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from ServiceRequestStatus where ID=@ID", ID);
                if (!_ok) m_db.LastError = "ServiceRequestStatus.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region ServiceRequestType
		//**********************************************************
		//  ServiceRequestType
		//**********************************************************
        CMD_ServiceRequestType m_ServiceRequestType = null;
        public CMD_ServiceRequestType ServiceRequestType
        {
            get
            {
				if (m_ServiceRequestType == null)
					m_ServiceRequestType = new CMD_ServiceRequestType(this);
				return m_ServiceRequestType;
			}
        }

		[Serializable]
		public class TBL_ServiceRequestType
		{
			public int ID { get; set; }
			public string ServiceFormType { get; set; }
			public string ServiceFormCode { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public int ModifiedBy { get; set; }
			public DateTime ModifiedDateTime { get; set; }

			public TBL_ServiceRequestType()
			{
				this.ID = 0;
				this.ServiceFormType = "";
				this.ServiceFormCode = "";
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ModifiedBy = 0;
				this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
			}

			public TBL_ServiceRequestType(int ID, string ServiceFormType, string ServiceFormCode, int CreatedBy, DateTime CreatedDatetime, int ModifiedBy, DateTime ModifiedDateTime)
			{
				this.ID = ID;
				this.ServiceFormType = ServiceFormType;
				this.ServiceFormCode = ServiceFormCode;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.ModifiedBy = ModifiedBy;
				this.ModifiedDateTime = ModifiedDateTime;
			}

			public void CopyTo(ref TBL_ServiceRequestType to)
			{
				to.ID = this.ID;
				to.ServiceFormType = this.ServiceFormType;
				to.ServiceFormCode = this.ServiceFormCode;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.ModifiedBy = this.ModifiedBy;
				to.ModifiedDateTime = this.ModifiedDateTime;
			}

			public bool IsSame(TBL_ServiceRequestType x)
			{
				return(
					this.ID == x.ID &&
					this.ServiceFormType == x.ServiceFormType &&
					this.ServiceFormCode == x.ServiceFormCode &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.ModifiedBy == x.ModifiedBy &&
					this.ModifiedDateTime == x.ModifiedDateTime
				);
			}

			public static TBL_ServiceRequestType ReadRow(DataRow row)
			{
				TBL_ServiceRequestType record = new TBL_ServiceRequestType();
				record.ID = get_int_value(row["ID"]);
				record.ServiceFormType = get_string_value(row["ServiceFormType"]);
				record.ServiceFormCode = get_string_value(row["ServiceFormCode"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.ModifiedBy = get_int_value(row["ModifiedBy"]);
				record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
				return record;
			}

			public static List<TBL_ServiceRequestType> ReadTable(DataTable dt)
			{
				List<TBL_ServiceRequestType> records = new List<TBL_ServiceRequestType>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_ServiceRequestType
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_ServiceRequestType(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_ServiceRequestType data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, ServiceFormType, ServiceFormCode, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from ServiceRequestType
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "ServiceRequestType.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "ServiceRequestType.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_ServiceRequestType.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ServiceRequestType.ID, ServiceRequestType.ServiceFormType, ServiceRequestType.ServiceFormCode, ServiceRequestType.CreatedBy, ServiceRequestType.CreatedDatetime, ServiceRequestType.ModifiedBy, ServiceRequestType.ModifiedDateTime
					from ServiceRequestType
					where ServiceRequestType.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "ServiceRequestType.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, ServiceFormType, ServiceFormCode, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from ServiceRequestType
					", ref dt);
                if (!_ok) m_db.LastError = "ServiceRequestType.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "ServiceRequestType.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ServiceRequestType.ID, ServiceRequestType.ServiceFormType, ServiceRequestType.ServiceFormCode, ServiceRequestType.CreatedBy, ServiceRequestType.CreatedDatetime, ServiceRequestType.ModifiedBy, ServiceRequestType.ModifiedDateTime
					from ServiceRequestType
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "ServiceRequestType.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ServiceRequestType.ID, ServiceRequestType.ServiceFormType, ServiceRequestType.ServiceFormCode, ServiceRequestType.CreatedBy, ServiceRequestType.CreatedDatetime, ServiceRequestType.ModifiedBy, ServiceRequestType.ModifiedDateTime
					from ServiceRequestType
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "ServiceRequestType.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int ID,
				string ServiceFormType,
				string ServiceFormCode,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime
			)
			{            
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ServiceRequestType where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ServiceRequestType.insert error.\r\n" + m_db.LastError;
					return false;
				}
				if (count > 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ServiceRequestType.insert error. ID duplicate";
					return false;
				}

				bool _ok = m_db.ExecSqlCmd(@"
					insert into ServiceRequestType(
						ID,
						ServiceFormType,
						ServiceFormCode,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@ID,
						@ServiceFormType,
						@ServiceFormCode,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", ID, ServiceFormType, ServiceFormCode, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);
                if (!_ok) m_db.LastError = "ServiceRequestType.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int _old_ID,
				int _new_ID,
				string ServiceFormType,
				string ServiceFormCode,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ServiceRequestType where ID=@_old_ID", ref count, _old_ID))
				{
					m_db.LastError = "ServiceRequestType.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ServiceRequestType.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update ServiceRequestType
					set
						ID = @_new_ID,
						ServiceFormType = @ServiceFormType,
						ServiceFormCode = @ServiceFormCode,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime
					where ID=@_old_ID
					",
					_new_ID,
					ServiceFormType,
					ServiceFormCode,
					CreatedBy,
					CreatedDatetime,
					ModifiedBy,
					ModifiedDateTime,
					_old_ID
				);
                if (!_ok) m_db.LastError = "ServiceRequestType.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from ServiceRequestType where ID=@ID", ref count, ID))
				{
					m_db.LastError = "ServiceRequestType.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "ServiceRequestType.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from ServiceRequestType where ID=@ID", ID);
                if (!_ok) m_db.LastError = "ServiceRequestType.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region BUsInAgency
		//**********************************************************
		//  BUsInAgency
		//**********************************************************
        CMD_BUsInAgency m_BUsInAgency = null;
        public CMD_BUsInAgency BUsInAgency
        {
            get
            {
				if (m_BUsInAgency == null)
					m_BUsInAgency = new CMD_BUsInAgency(this);
				return m_BUsInAgency;
			}
        }

		[Serializable]
		public class TBL_BUsInAgency
		{
			public int ID { get; set; }
			public int AgencyID { get; set; }
			public string BUIDName { get; set; }
			public string BUName { get; set; }
			public int BUStatus { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public int ModifiedBy { get; set; }
			public DateTime ModifiedDateTime { get; set; }

			public TBL_BUsInAgency()
			{
				this.ID = 0;
				this.AgencyID = 0;
				this.BUIDName = "";
				this.BUName = "";
				this.BUStatus = 0;
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ModifiedBy = 0;
				this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
			}

			public TBL_BUsInAgency(int ID, int AgencyID, string BUIDName, string BUName, int BUStatus, int CreatedBy, DateTime CreatedDatetime, int ModifiedBy, DateTime ModifiedDateTime)
			{
				this.ID = ID;
				this.AgencyID = AgencyID;
				this.BUIDName = BUIDName;
				this.BUName = BUName;
				this.BUStatus = BUStatus;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.ModifiedBy = ModifiedBy;
				this.ModifiedDateTime = ModifiedDateTime;
			}

			public void CopyTo(ref TBL_BUsInAgency to)
			{
				to.ID = this.ID;
				to.AgencyID = this.AgencyID;
				to.BUIDName = this.BUIDName;
				to.BUName = this.BUName;
				to.BUStatus = this.BUStatus;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.ModifiedBy = this.ModifiedBy;
				to.ModifiedDateTime = this.ModifiedDateTime;
			}

			public bool IsSame(TBL_BUsInAgency x)
			{
				return(
					this.ID == x.ID &&
					this.AgencyID == x.AgencyID &&
					this.BUIDName == x.BUIDName &&
					this.BUName == x.BUName &&
					this.BUStatus == x.BUStatus &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.ModifiedBy == x.ModifiedBy &&
					this.ModifiedDateTime == x.ModifiedDateTime
				);
			}

			public static TBL_BUsInAgency ReadRow(DataRow row)
			{
				TBL_BUsInAgency record = new TBL_BUsInAgency();
				record.ID = get_int_value(row["ID"]);
				record.AgencyID = get_int_value(row["AgencyID"]);
				record.BUIDName = get_string_value(row["BUIDName"]);
				record.BUName = get_string_value(row["BUName"]);
				record.BUStatus = get_int_value(row["BUStatus"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.ModifiedBy = get_int_value(row["ModifiedBy"]);
				record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
				return record;
			}

			public static List<TBL_BUsInAgency> ReadTable(DataTable dt)
			{
				List<TBL_BUsInAgency> records = new List<TBL_BUsInAgency>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_BUsInAgency
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_BUsInAgency(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int ID,
				ref TBL_BUsInAgency data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select ID, AgencyID, BUIDName, BUName, BUStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from BUsInAgency
					where ID=@ID
					", ref dt, ID))
                {
                    m_db.LastError = "BUsInAgency.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "BUsInAgency.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_BUsInAgency.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int ID,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select BUsInAgency.ID, BUsInAgency.AgencyID, BUsInAgency.BUIDName, BUsInAgency.BUName, BUsInAgency.BUStatus, BUsInAgency.CreatedBy, BUsInAgency.CreatedDatetime, BUsInAgency.ModifiedBy, BUsInAgency.ModifiedDateTime
					from BUsInAgency
					where BUsInAgency.ID=@ID
					", ref dt, ID);
                if (!_ok) m_db.LastError = "BUsInAgency.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select ID, AgencyID, BUIDName, BUName, BUStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from BUsInAgency
					", ref dt);
                if (!_ok) m_db.LastError = "BUsInAgency.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "BUsInAgency.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select BUsInAgency.ID, BUsInAgency.AgencyID, BUsInAgency.BUIDName, BUsInAgency.BUName, BUsInAgency.BUStatus, BUsInAgency.CreatedBy, BUsInAgency.CreatedDatetime, BUsInAgency.ModifiedBy, BUsInAgency.ModifiedDateTime
					from BUsInAgency
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "BUsInAgency.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select BUsInAgency.ID, BUsInAgency.AgencyID, BUsInAgency.BUIDName, BUsInAgency.BUName, BUsInAgency.BUStatus, BUsInAgency.CreatedBy, BUsInAgency.CreatedDatetime, BUsInAgency.ModifiedBy, BUsInAgency.ModifiedDateTime
					from BUsInAgency
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "BUsInAgency.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				int AgencyID,
				string BUIDName,
				string BUName,
				int BUStatus,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into BUsInAgency(
						AgencyID,
						BUIDName,
						BUName,
						BUStatus,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@AgencyID,
						@BUIDName,
						@BUName,
						@BUStatus,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", AgencyID, BUIDName, BUName, BUStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);
                if (!_ok) m_db.LastError = "BUsInAgency.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int ID,
				int AgencyID,
				string BUIDName,
				string BUName,
				int BUStatus,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from BUsInAgency where ID=@ID", ref count, ID))
				{
					m_db.LastError = "BUsInAgency.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "BUsInAgency.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update BUsInAgency
					set
						AgencyID = @AgencyID,
						BUIDName = @BUIDName,
						BUName = @BUName,
						BUStatus = @BUStatus,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime
					where ID=@ID
					",
					AgencyID,
					BUIDName,
					BUName,
					BUStatus,
					CreatedBy,
					CreatedDatetime,
					ModifiedBy,
					ModifiedDateTime,
					ID
				);
                if (!_ok) m_db.LastError = "BUsInAgency.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int ID
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from BUsInAgency where ID=@ID", ref count, ID))
				{
					m_db.LastError = "BUsInAgency.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "BUsInAgency.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from BUsInAgency where ID=@ID", ID);
                if (!_ok) m_db.LastError = "BUsInAgency.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region sysdiagrams
		//**********************************************************
		//  sysdiagrams
		//**********************************************************
        CMD_sysdiagrams m_sysdiagrams = null;
        public CMD_sysdiagrams sysdiagrams
        {
            get
            {
				if (m_sysdiagrams == null)
					m_sysdiagrams = new CMD_sysdiagrams(this);
				return m_sysdiagrams;
			}
        }

		[Serializable]
		public class TBL_sysdiagrams
		{
			public string name { get; set; }
			public int principal_id { get; set; }
			public int diagram_id { get; set; }
			public int version { get; set; }
			public object definition { get; set; }

			public TBL_sysdiagrams()
			{
				this.name = "";
				this.principal_id = 0;
				this.diagram_id = 0;
				this.version = 0;
				this.definition = null;
			}

			public TBL_sysdiagrams(string name, int principal_id, int diagram_id, int version, object definition)
			{
				this.name = name;
				this.principal_id = principal_id;
				this.diagram_id = diagram_id;
				this.version = version;
				this.definition = definition;
			}

			public void CopyTo(ref TBL_sysdiagrams to)
			{
				to.name = this.name;
				to.principal_id = this.principal_id;
				to.diagram_id = this.diagram_id;
				to.version = this.version;
				to.definition = this.definition;
			}

			public bool IsSame(TBL_sysdiagrams x)
			{
				return(
					this.name == x.name &&
					this.principal_id == x.principal_id &&
					this.diagram_id == x.diagram_id &&
					this.version == x.version &&
					this.definition == x.definition
				);
			}

			public static TBL_sysdiagrams ReadRow(DataRow row)
			{
				TBL_sysdiagrams record = new TBL_sysdiagrams();
				record.name = get_string_value(row["name"]);
				record.principal_id = get_int_value(row["principal_id"]);
				record.diagram_id = get_int_value(row["diagram_id"]);
				record.version = get_int_value(row["version"]);
				record.definition = get_object_value(row["definition"]);
				return record;
			}

			public static List<TBL_sysdiagrams> ReadTable(DataTable dt)
			{
				List<TBL_sysdiagrams> records = new List<TBL_sysdiagrams>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_sysdiagrams
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_sysdiagrams(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int diagram_id,
				ref TBL_sysdiagrams data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select name, principal_id, diagram_id, version, definition
					from sysdiagrams
					where diagram_id=@diagram_id
					", ref dt, diagram_id))
                {
                    m_db.LastError = "sysdiagrams.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "sysdiagrams.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_sysdiagrams.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int diagram_id,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select sysdiagrams.name, sysdiagrams.principal_id, sysdiagrams.diagram_id, sysdiagrams.version, sysdiagrams.definition
					from sysdiagrams
					where sysdiagrams.diagram_id=@diagram_id
					", ref dt, diagram_id);
                if (!_ok) m_db.LastError = "sysdiagrams.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select name, principal_id, diagram_id, version, definition
					from sysdiagrams
					", ref dt);
                if (!_ok) m_db.LastError = "sysdiagrams.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "sysdiagrams.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select sysdiagrams.name, sysdiagrams.principal_id, sysdiagrams.diagram_id, sysdiagrams.version, sysdiagrams.definition
					from sysdiagrams
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "sysdiagrams.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select sysdiagrams.name, sysdiagrams.principal_id, sysdiagrams.diagram_id, sysdiagrams.version, sysdiagrams.definition
					from sysdiagrams
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "sysdiagrams.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				string name,
				int principal_id,
				int version,
				object definition
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into sysdiagrams(
						name,
						principal_id,
						version,
						definition
						)
					values(
						@name,
						@principal_id,
						@version,
						@definition
						)
					", name, principal_id, version, definition);
                if (!_ok) m_db.LastError = "sysdiagrams.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int diagram_id,
				string name,
				int principal_id,
				int version,
				object definition
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from sysdiagrams where diagram_id=@diagram_id", ref count, diagram_id))
				{
					m_db.LastError = "sysdiagrams.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "sysdiagrams.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update sysdiagrams
					set
						name = @name,
						principal_id = @principal_id,
						version = @version,
						definition = @definition
					where diagram_id=@diagram_id
					",
					name,
					principal_id,
					version,
					definition,
					diagram_id
				);
                if (!_ok) m_db.LastError = "sysdiagrams.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int diagram_id
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from sysdiagrams where diagram_id=@diagram_id", ref count, diagram_id))
				{
					m_db.LastError = "sysdiagrams.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "sysdiagrams.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from sysdiagrams where diagram_id=@diagram_id", diagram_id);
                if (!_ok) m_db.LastError = "sysdiagrams.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion

		#region UserProfile
		//**********************************************************
		//  UserProfile
		//**********************************************************
        CMD_UserProfile m_UserProfile = null;
        public CMD_UserProfile UserProfile
        {
            get
            {
				if (m_UserProfile == null)
					m_UserProfile = new CMD_UserProfile(this);
				return m_UserProfile;
			}
        }

		[Serializable]
		public class TBL_UserProfile
		{
			public int UserId { get; set; }
			public string LoginId { get; set; }
			public string LoginPassword { get; set; }
			public string NRIC { get; set; }
			public string Name0 { get; set; }
			public string Address01 { get; set; }
			public string Address02 { get; set; }
			public string PostCode { get; set; }
			public string PrimaryPhone { get; set; }
			public string SecondaryPhone { get; set; }
			public string FaxNumber { get; set; }
			public string Email { get; set; }
			public int UserTypeId { get; set; }
			public int AgencyID { get; set; }
			public int BUID { get; set; }
			public int CostCentreID { get; set; }
			public int UserStatus { get; set; }
			public int CreatedBy { get; set; }
			public DateTime CreatedDatetime { get; set; }
			public int ModifiedBy { get; set; }
			public DateTime ModifiedDateTime { get; set; }
			public DateTime LastLogin { get; set; }

			public TBL_UserProfile()
			{
				this.UserId = 0;
				this.LoginId = "";
				this.LoginPassword = "";
				this.NRIC = "";
				this.Name0 = "";
				this.Address01 = "";
				this.Address02 = "";
				this.PostCode = "";
				this.PrimaryPhone = "";
				this.SecondaryPhone = "";
				this.FaxNumber = "";
				this.Email = "";
				this.UserTypeId = 0;
				this.AgencyID = 0;
				this.BUID = 0;
				this.CostCentreID = 0;
				this.UserStatus = 0;
				this.CreatedBy = 0;
				this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.ModifiedBy = 0;
				this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
				this.LastLogin = Convert.ToDateTime("1900-01-01 00:00:00");
			}

			public TBL_UserProfile(int UserId, string LoginId, string LoginPassword, string NRIC, string Name0, string Address01, string Address02, string PostCode, string PrimaryPhone, string SecondaryPhone, string FaxNumber, string Email, int UserTypeId, int AgencyID, int BUID, int CostCentreID, int UserStatus, int CreatedBy, DateTime CreatedDatetime, int ModifiedBy, DateTime ModifiedDateTime, DateTime LastLogin)
			{
				this.UserId = UserId;
				this.LoginId = LoginId;
				this.LoginPassword = LoginPassword;
				this.NRIC = NRIC;
				this.Name0 = Name0;
				this.Address01 = Address01;
				this.Address02 = Address02;
				this.PostCode = PostCode;
				this.PrimaryPhone = PrimaryPhone;
				this.SecondaryPhone = SecondaryPhone;
				this.FaxNumber = FaxNumber;
				this.Email = Email;
				this.UserTypeId = UserTypeId;
				this.AgencyID = AgencyID;
				this.BUID = BUID;
				this.CostCentreID = CostCentreID;
				this.UserStatus = UserStatus;
				this.CreatedBy = CreatedBy;
				this.CreatedDatetime = CreatedDatetime;
				this.ModifiedBy = ModifiedBy;
				this.ModifiedDateTime = ModifiedDateTime;
				this.LastLogin = LastLogin;
			}

			public void CopyTo(ref TBL_UserProfile to)
			{
				to.UserId = this.UserId;
				to.LoginId = this.LoginId;
				to.LoginPassword = this.LoginPassword;
				to.NRIC = this.NRIC;
				to.Name0 = this.Name0;
				to.Address01 = this.Address01;
				to.Address02 = this.Address02;
				to.PostCode = this.PostCode;
				to.PrimaryPhone = this.PrimaryPhone;
				to.SecondaryPhone = this.SecondaryPhone;
				to.FaxNumber = this.FaxNumber;
				to.Email = this.Email;
				to.UserTypeId = this.UserTypeId;
				to.AgencyID = this.AgencyID;
				to.BUID = this.BUID;
				to.CostCentreID = this.CostCentreID;
				to.UserStatus = this.UserStatus;
				to.CreatedBy = this.CreatedBy;
				to.CreatedDatetime = this.CreatedDatetime;
				to.ModifiedBy = this.ModifiedBy;
				to.ModifiedDateTime = this.ModifiedDateTime;
				to.LastLogin = this.LastLogin;
			}

			public bool IsSame(TBL_UserProfile x)
			{
				return(
					this.UserId == x.UserId &&
					this.LoginId == x.LoginId &&
					this.LoginPassword == x.LoginPassword &&
					this.NRIC == x.NRIC &&
					this.Name0 == x.Name0 &&
					this.Address01 == x.Address01 &&
					this.Address02 == x.Address02 &&
					this.PostCode == x.PostCode &&
					this.PrimaryPhone == x.PrimaryPhone &&
					this.SecondaryPhone == x.SecondaryPhone &&
					this.FaxNumber == x.FaxNumber &&
					this.Email == x.Email &&
					this.UserTypeId == x.UserTypeId &&
					this.AgencyID == x.AgencyID &&
					this.BUID == x.BUID &&
					this.CostCentreID == x.CostCentreID &&
					this.UserStatus == x.UserStatus &&
					this.CreatedBy == x.CreatedBy &&
					this.CreatedDatetime == x.CreatedDatetime &&
					this.ModifiedBy == x.ModifiedBy &&
					this.ModifiedDateTime == x.ModifiedDateTime &&
					this.LastLogin == x.LastLogin
				);
			}

			public static TBL_UserProfile ReadRow(DataRow row)
			{
				TBL_UserProfile record = new TBL_UserProfile();
				record.UserId = get_int_value(row["UserId"]);
				record.LoginId = get_string_value(row["LoginId"]);
				record.LoginPassword = get_string_value(row["LoginPassword"]);
				record.NRIC = get_string_value(row["NRIC"]);
				record.Name0 = get_string_value(row["Name0"]);
				record.Address01 = get_string_value(row["Address01"]);
				record.Address02 = get_string_value(row["Address02"]);
				record.PostCode = get_string_value(row["PostCode"]);
				record.PrimaryPhone = get_string_value(row["PrimaryPhone"]);
				record.SecondaryPhone = get_string_value(row["SecondaryPhone"]);
				record.FaxNumber = get_string_value(row["FaxNumber"]);
				record.Email = get_string_value(row["Email"]);
				record.UserTypeId = get_int_value(row["UserTypeId"]);
				record.AgencyID = get_int_value(row["AgencyID"]);
				record.BUID = get_int_value(row["BUID"]);
				record.CostCentreID = get_int_value(row["CostCentreID"]);
				record.UserStatus = get_int_value(row["UserStatus"]);
				record.CreatedBy = get_int_value(row["CreatedBy"]);
				record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
				record.ModifiedBy = get_int_value(row["ModifiedBy"]);
				record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
				record.LastLogin = get_DateTime_value(row["LastLogin"]);
				return record;
			}

			public static List<TBL_UserProfile> ReadTable(DataTable dt)
			{
				List<TBL_UserProfile> records = new List<TBL_UserProfile>();
				foreach(DataRow row in dt.Rows)
					records.Add(ReadRow(row));
				return records;
			}
		}

        public class CMD_UserProfile
        {
            private MyLib.DBCommandsBase m_db = null;

			public CMD_UserProfile(MyLib.DBCommandsBase db)
			{
				m_db = db;
			}

			public bool select
			(
				int UserId,
				ref TBL_UserProfile data
			)
			{
                DataTable dt = new DataTable();
				if (!m_db.ExecSqlQuery(@"
					select UserId, LoginId, LoginPassword, NRIC, Name0, Address01, Address02, PostCode, PrimaryPhone, SecondaryPhone, FaxNumber, Email, UserTypeId, AgencyID, BUID, CostCentreID, UserStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, LastLogin
					from UserProfile
					where UserId=@UserId
					", ref dt, UserId))
                {
                    m_db.LastError = "UserProfile.select error.\r\n" + m_db.LastError;
                    return false;
                }
                if (dt.Rows.Count == 0)
                {
                    m_db.LastError = "UserProfile.select error.\r\nRecord does not exist.";
                    return false;
                }
                data = TBL_UserProfile.ReadRow(dt.Rows[0]);
                return true;
			}

			public bool select_join
			(
				int UserId,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select UserProfile.UserId, UserProfile.LoginId, UserProfile.LoginPassword, UserProfile.NRIC, UserProfile.Name0, UserProfile.Address01, UserProfile.Address02, UserProfile.PostCode, UserProfile.PrimaryPhone, UserProfile.SecondaryPhone, UserProfile.FaxNumber, UserProfile.Email, UserProfile.UserTypeId, UserProfile.AgencyID, UserProfile.BUID, UserProfile.CostCentreID, UserProfile.UserStatus, UserProfile.CreatedBy, UserProfile.CreatedDatetime, UserProfile.ModifiedBy, UserProfile.ModifiedDateTime, UserProfile.LastLogin
					from UserProfile
					where UserProfile.UserId=@UserId
					", ref dt, UserId);
                if (!_ok) m_db.LastError = "UserProfile.select error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all
			(
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select UserId, LoginId, LoginPassword, NRIC, Name0, Address01, Address02, PostCode, PrimaryPhone, SecondaryPhone, FaxNumber, Email, UserTypeId, AgencyID, BUID, CostCentreID, UserStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, LastLogin
					from UserProfile
					", ref dt);
                if (!_ok) m_db.LastError = "UserProfile.select_all error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt
			)
			{
				bool _ok = select_all_join(ref dt, "");
				if (!_ok) m_db.LastError = "UserProfile.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool select_all_join
			(
				ref DataTable dt,
				string where_clause,
                params object[] inputs
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select UserProfile.UserId, UserProfile.LoginId, UserProfile.LoginPassword, UserProfile.NRIC, UserProfile.Name0, UserProfile.Address01, UserProfile.Address02, UserProfile.PostCode, UserProfile.PrimaryPhone, UserProfile.SecondaryPhone, UserProfile.FaxNumber, UserProfile.Email, UserProfile.UserTypeId, UserProfile.AgencyID, UserProfile.BUID, UserProfile.CostCentreID, UserProfile.UserStatus, UserProfile.CreatedBy, UserProfile.CreatedDatetime, UserProfile.ModifiedBy, UserProfile.ModifiedDateTime, UserProfile.LastLogin
					from UserProfile
					" + where_clause, ref dt, inputs);
                if (!_ok) m_db.LastError = "UserProfile.select_all_join error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool query
			(
				string where_clause,
				ref DataTable dt
			)
			{
				bool _ok = m_db.ExecSqlQuery(@"
					select UserProfile.UserId, UserProfile.LoginId, UserProfile.LoginPassword, UserProfile.NRIC, UserProfile.Name0, UserProfile.Address01, UserProfile.Address02, UserProfile.PostCode, UserProfile.PrimaryPhone, UserProfile.SecondaryPhone, UserProfile.FaxNumber, UserProfile.Email, UserProfile.UserTypeId, UserProfile.AgencyID, UserProfile.BUID, UserProfile.CostCentreID, UserProfile.UserStatus, UserProfile.CreatedBy, UserProfile.CreatedDatetime, UserProfile.ModifiedBy, UserProfile.ModifiedDateTime, UserProfile.LastLogin
					from UserProfile
					" + " " + where_clause, ref dt);
                if (!_ok) m_db.LastError = "UserProfile.query error.\r\n" + m_db.LastError;
                return _ok;
			}


            public bool insert
			(
				string LoginId,
				string LoginPassword,
				string NRIC,
				string Name0,
				string Address01,
				string Address02,
				string PostCode,
				string PrimaryPhone,
				string SecondaryPhone,
				string FaxNumber,
				string Email,
				int UserTypeId,
				int AgencyID,
				int BUID,
				int CostCentreID,
				int UserStatus,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime,
				DateTime LastLogin
			)
			{            
				bool _ok = m_db.ExecSqlCmd(@"
					insert into UserProfile(
						LoginId,
						LoginPassword,
						NRIC,
						Name0,
						Address01,
						Address02,
						PostCode,
						PrimaryPhone,
						SecondaryPhone,
						FaxNumber,
						Email,
						UserTypeId,
						AgencyID,
						BUID,
						CostCentreID,
						UserStatus,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime,
						LastLogin
						)
					values(
						@LoginId,
						@LoginPassword,
						@NRIC,
						@Name0,
						@Address01,
						@Address02,
						@PostCode,
						@PrimaryPhone,
						@SecondaryPhone,
						@FaxNumber,
						@Email,
						@UserTypeId,
						@AgencyID,
						@BUID,
						@CostCentreID,
						@UserStatus,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime,
						@LastLogin
						)
					", LoginId, LoginPassword, NRIC, Name0, Address01, Address02, PostCode, PrimaryPhone, SecondaryPhone, FaxNumber, Email, UserTypeId, AgencyID, BUID, CostCentreID, UserStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, LastLogin);
                if (!_ok) m_db.LastError = "UserProfile.insert error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool update
			(
				int UserId,
				string LoginId,
				string LoginPassword,
				string NRIC,
				string Name0,
				string Address01,
				string Address02,
				string PostCode,
				string PrimaryPhone,
				string SecondaryPhone,
				string FaxNumber,
				string Email,
				int UserTypeId,
				int AgencyID,
				int BUID,
				int CostCentreID,
				int UserStatus,
				int CreatedBy,
				DateTime CreatedDatetime,
				int ModifiedBy,
				DateTime ModifiedDateTime,
				DateTime LastLogin
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from UserProfile where UserId=@UserId", ref count, UserId))
				{
					m_db.LastError = "UserProfile.update error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "UserProfile.update error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"
					update UserProfile
					set
						LoginId = @LoginId,
						LoginPassword = @LoginPassword,
						NRIC = @NRIC,
						Name0 = @Name0,
						Address01 = @Address01,
						Address02 = @Address02,
						PostCode = @PostCode,
						PrimaryPhone = @PrimaryPhone,
						SecondaryPhone = @SecondaryPhone,
						FaxNumber = @FaxNumber,
						Email = @Email,
						UserTypeId = @UserTypeId,
						AgencyID = @AgencyID,
						BUID = @BUID,
						CostCentreID = @CostCentreID,
						UserStatus = @UserStatus,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime,
						LastLogin = @LastLogin
					where UserId=@UserId
					",
					LoginId,
					LoginPassword,
					NRIC,
					Name0,
					Address01,
					Address02,
					PostCode,
					PrimaryPhone,
					SecondaryPhone,
					FaxNumber,
					Email,
					UserTypeId,
					AgencyID,
					BUID,
					CostCentreID,
					UserStatus,
					CreatedBy,
					CreatedDatetime,
					ModifiedBy,
					ModifiedDateTime,
					LastLogin,
					UserId
				);
                if (!_ok) m_db.LastError = "UserProfile.update error.\r\n" + m_db.LastError;
                return _ok;
			}

			public bool delete
			(				
				int UserId
			)
			{
				int count = 0;
				if (!m_db.ExecSqlQueryCount(@"select * from UserProfile where UserId=@UserId", ref count, UserId))
				{
					m_db.LastError = "UserProfile.delete error.\r\n" + m_db.LastError;
					return false;
				}
				if (count == 0)
				{
					m_db.LastErrorCode = -1;
					m_db.LastError = "UserProfile.delete error. ID does not exists";
					return false;
				}
                
				bool _ok = m_db.ExecSqlCmd(@"delete from UserProfile where UserId=@UserId", UserId);
                if (!_ok) m_db.LastError = "UserProfile.delete error.\r\n" + m_db.LastError;
                return _ok;
			}
        
		}

		#endregion


		public bool sp_alterdiagram
		(
			string diagramname,
			int owner_id,
			int version,
			object definition
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("sp_alterdiagram", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@diagramname", SqlDbType.VarChar, 256, 128, 0, ParameterDirection.Input, diagramname);
				AddParam(sqlCmd, "@owner_id", SqlDbType.Int, 4, 10, 0, ParameterDirection.Input, owner_id);
				AddParam(sqlCmd, "@version", SqlDbType.Int, 4, 10, 0, ParameterDirection.Input, version);
				AddParam(sqlCmd, "@definition", SqlDbType.VarBinary, -1, -1, 0, ParameterDirection.Input, definition);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "sp_alterdiagram error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_AttachmentsInNotice_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_AttachmentsInNotice_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_AttachmentsInNotice_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_AttachmentsInNotice_DeleteByNoticeID
		(
			int NoticeID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_AttachmentsInNotice_DeleteByNoticeID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@NoticeID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, NoticeID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_AttachmentsInNotice_DeleteByNoticeID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_AttachmentsInNotice_Insert
		(
			int NoticeID,
			object AttachmentDetails,
			string AttachmentName,
			string AttachmentContentType,
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_AttachmentsInNotice_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@NoticeID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, NoticeID);
				AddParam(sqlCmd, "@AttachmentDetails", SqlDbType.Binary, 16, 0, 0, ParameterDirection.Input, AttachmentDetails);
				AddParam(sqlCmd, "@AttachmentName", SqlDbType.VarChar, 200, 100, 0, ParameterDirection.Input, AttachmentName);
				AddParam(sqlCmd, "@AttachmentContentType", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, AttachmentContentType);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_AttachmentsInNotice_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_AttachmentsInNotice_SelectAll
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_AttachmentsInNotice_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_AttachmentsInNotice_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool sp_AttachmentsInNotice_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("sp_AttachmentsInNotice_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "sp_AttachmentsInNotice_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_AttachmentsInNotice_SelectByNoticeID
		(
			int NoticeID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_AttachmentsInNotice_SelectByNoticeID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@NoticeID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, NoticeID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_AttachmentsInNotice_SelectByNoticeID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_AttachmentsInNotice_UpdateByID
		(
			int ID,
			int NoticeID,
			object AttachmentDetails,
			string AttachmentName,
			string AttachmentContentType,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_AttachmentsInNotice_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@NoticeID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, NoticeID);
				AddParam(sqlCmd, "@AttachmentDetails", SqlDbType.Binary, 16, 0, 0, ParameterDirection.Input, AttachmentDetails);
				AddParam(sqlCmd, "@AttachmentName", SqlDbType.VarChar, 200, 100, 0, ParameterDirection.Input, AttachmentName);
				AddParam(sqlCmd, "@AttachmentContentType", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, AttachmentContentType);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_AttachmentsInNotice_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_AuditTrail_Insert
		(
			DateTime datetime,
			string script,
			string user,
			string action,
			string table,
			string field,
			string keyvalue,
			string oldvalue,
			string newvalue
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_AuditTrail_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@datetime", SqlDbType.DateTime, 8, 23, 3, ParameterDirection.Input, datetime);
				AddParam(sqlCmd, "@script", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, script);
				AddParam(sqlCmd, "@user", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, user);
				AddParam(sqlCmd, "@action", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, action);
				AddParam(sqlCmd, "@table", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, table);
				AddParam(sqlCmd, "@field", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, field);
				AddParam(sqlCmd, "@keyvalue", SqlDbType.VarChar, 16, 0, 0, ParameterDirection.Input, keyvalue);
				AddParam(sqlCmd, "@oldvalue", SqlDbType.VarChar, 16, 0, 0, ParameterDirection.Input, oldvalue);
				AddParam(sqlCmd, "@newvalue", SqlDbType.VarChar, 16, 0, 0, ParameterDirection.Input, newvalue);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_AuditTrail_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool sp_BackupDatabase
		(
			string databaseName,
			string backupType
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("sp_BackupDatabase", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@databaseName", SqlDbType.VarChar, 256, 128, 0, ParameterDirection.Input, databaseName);
				AddParam(sqlCmd, "@backupType", SqlDbType.VarChar, 1, 1, 0, ParameterDirection.Input, backupType);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "sp_BackupDatabase error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Bill_Generate
		(
			int BillPeriodID,
			ref string GenerateOutput
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Bill_Generate", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@GenerateOutput", SqlDbType.VarChar, -1, -1, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				GenerateOutput = get_string_value(sqlCmd.Parameters["@GenerateOutput"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Bill_Generate error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillConfig_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillConfig_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillConfig_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomer_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomer_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomer_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomer_Insert
		(
			string BillType,
			string CustNo,
			string CustName1,
			string CustName2,
			string BUCode,
			string Address,
			string ContactPerson,
			string PaymentTerm,
			string SpecialInstruction,
			string GroupBy,
			int BUID,
			string TelNo,
			string FaxNo,
			string EmailTo,
			string Remarks,
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomer_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillType", SqlDbType.VarChar, 40, 20, 0, ParameterDirection.Input, BillType);
				AddParam(sqlCmd, "@CustNo", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, CustNo);
				AddParam(sqlCmd, "@CustName1", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, CustName1);
				AddParam(sqlCmd, "@CustName2", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, CustName2);
				AddParam(sqlCmd, "@BUCode", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, BUCode);
				AddParam(sqlCmd, "@Address", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, Address);
				AddParam(sqlCmd, "@ContactPerson", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ContactPerson);
				AddParam(sqlCmd, "@PaymentTerm", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, PaymentTerm);
				AddParam(sqlCmd, "@SpecialInstruction", SqlDbType.VarChar, 1000, 500, 0, ParameterDirection.Input, SpecialInstruction);
				AddParam(sqlCmd, "@GroupBy", SqlDbType.VarChar, 40, 20, 0, ParameterDirection.Input, GroupBy);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@TelNo", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, TelNo);
				AddParam(sqlCmd, "@FaxNo", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, FaxNo);
				AddParam(sqlCmd, "@EmailTo", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, EmailTo);
				AddParam(sqlCmd, "@Remarks", SqlDbType.VarChar, 16, 0, 0, ParameterDirection.Input, Remarks);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomer_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomer_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomer_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomer_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomer_SelectByBillingRecipientEmail
		(
			string Email
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomer_SelectByBillingRecipientEmail", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@Email", SqlDbType.VarChar, 200, 200, 0, ParameterDirection.Input, Email);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomer_SelectByBillingRecipientEmail error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomer_SelectByBillType
		(
			string BillType
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomer_SelectByBillType", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillType", SqlDbType.VarChar, 40, 20, 0, ParameterDirection.Input, BillType);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomer_SelectByBillType error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomer_SelectByBillTypeAgencyID
		(
			string BillType,
			int AgencyID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomer_SelectByBillTypeAgencyID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillType", SqlDbType.VarChar, 40, 20, 0, ParameterDirection.Input, BillType);
				AddParam(sqlCmd, "@AgencyID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, AgencyID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomer_SelectByBillTypeAgencyID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomer_SelectByBillTypeBUID
		(
			string BillType,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomer_SelectByBillTypeBUID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillType", SqlDbType.VarChar, 40, 20, 0, ParameterDirection.Input, BillType);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomer_SelectByBillTypeBUID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomer_SelectByBillTypeBUIDCostCentreID
		(
			string BillType,
			int BUID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomer_SelectByBillTypeBUIDCostCentreID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillType", SqlDbType.VarChar, 40, 20, 0, ParameterDirection.Input, BillType);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomer_SelectByBillTypeBUIDCostCentreID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomer_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomer_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomer_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomer_UpdateByID
		(
			int ID,
			string BillType,
			string CustNo,
			string CustName1,
			string CustName2,
			string BUCode,
			string Address,
			string ContactPerson,
			string PaymentTerm,
			string SpecialInstruction,
			string GroupBy,
			int BUID,
			string TelNo,
			string FaxNo,
			string EmailTo,
			string Remarks,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomer_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@BillType", SqlDbType.VarChar, 40, 20, 0, ParameterDirection.Input, BillType);
				AddParam(sqlCmd, "@CustNo", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, CustNo);
				AddParam(sqlCmd, "@CustName1", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, CustName1);
				AddParam(sqlCmd, "@CustName2", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, CustName2);
				AddParam(sqlCmd, "@BUCode", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, BUCode);
				AddParam(sqlCmd, "@Address", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, Address);
				AddParam(sqlCmd, "@ContactPerson", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ContactPerson);
				AddParam(sqlCmd, "@PaymentTerm", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, PaymentTerm);
				AddParam(sqlCmd, "@SpecialInstruction", SqlDbType.VarChar, 1000, 500, 0, ParameterDirection.Input, SpecialInstruction);
				AddParam(sqlCmd, "@GroupBy", SqlDbType.VarChar, 40, 20, 0, ParameterDirection.Input, GroupBy);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@TelNo", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, TelNo);
				AddParam(sqlCmd, "@FaxNo", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, FaxNo);
				AddParam(sqlCmd, "@EmailTo", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, EmailTo);
				AddParam(sqlCmd, "@Remarks", SqlDbType.VarChar, 16, 0, 0, ParameterDirection.Input, Remarks);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomer_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomerCC_DeleteByBillCustomerID
		(
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomerCC_DeleteByBillCustomerID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomerCC_DeleteByBillCustomerID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomerCC_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomerCC_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomerCC_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomerCC_Insert
		(
			int BillCustomerID,
			int CostCentreID,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomerCC_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomerCC_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomerCC_SelectByBillCustomerID
		(
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomerCC_SelectByBillCustomerID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomerCC_SelectByBillCustomerID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomerCC_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomerCC_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomerCC_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillCustomerCC_UpdateByID
		(
			int ID,
			int BillCustomerID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillCustomerCC_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillCustomerCC_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPS_Generate
		(
			int BillPeriodID,
			ref string GenerateOutput
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPS_Generate", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@GenerateOutput", SqlDbType.VarChar, -1, -1, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				GenerateOutput = get_string_value(sqlCmd.Parameters["@GenerateOutput"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPS_Generate error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPS_SelectMainbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPS_SelectMainbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPS_SelectMainbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPS_SelectMainByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPS_SelectMainByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPS_SelectMainByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPS_SelectMainbyBillPeriodBU
		(
			int BillPeriodID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPS_SelectMainbyBillPeriodBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPS_SelectMainbyBillPeriodBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPS_SelectNonSE2BackupbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPS_SelectNonSE2BackupbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPS_SelectNonSE2BackupbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPS_SelectNonSE2BackupByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPS_SelectNonSE2BackupByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPS_SelectNonSE2BackupByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPS_SelectNonSE2BackupbyBillPeriodBU
		(
			int BillPeriodID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPS_SelectNonSE2BackupbyBillPeriodBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPS_SelectNonSE2BackupbyBillPeriodBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPS_SelectSE2BackupbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPS_SelectSE2BackupbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPS_SelectSE2BackupbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPS_SelectSE2BackupByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPS_SelectSE2BackupByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPS_SelectSE2BackupByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPS_SelectSE2BackupbyBillPeriodBU
		(
			int BillPeriodID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPS_SelectSE2BackupbyBillPeriodBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPS_SelectSE2BackupbyBillPeriodBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_Generate
		(
			int BillPeriodID,
			ref string GenerateOutput
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_Generate", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@GenerateOutput", SqlDbType.VarChar, -1, -1, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				GenerateOutput = get_string_value(sqlCmd.Parameters["@GenerateOutput"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_Generate error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectNonSE2BackupbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectNonSE2BackupbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectNonSE2BackupbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectNonSE2BackupByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectNonSE2BackupByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectNonSE2BackupByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectNonSE2BackupbyBillPeriodBU
		(
			int BillPeriodID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectNonSE2BackupbyBillPeriodBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectNonSE2BackupbyBillPeriodBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectNonSE2MainbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectNonSE2MainbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectNonSE2MainbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectNonSE2MainByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectNonSE2MainByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectNonSE2MainByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectNonSE2MainbyBillPeriodBU
		(
			int BillPeriodID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectNonSE2MainbyBillPeriodBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectNonSE2MainbyBillPeriodBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectSE2BackupbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectSE2BackupbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectSE2BackupbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectSE2BackupByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectSE2BackupByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectSE2BackupByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectSE2BackupbyBillPeriodBU
		(
			int BillPeriodID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectSE2BackupbyBillPeriodBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectSE2BackupbyBillPeriodBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectSE2MainbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectSE2MainbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectSE2MainbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectSE2MainByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectSE2MainByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectSE2MainByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectSE2MainbyBillPeriodBU
		(
			int BillPeriodID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectSE2MainbyBillPeriodBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectSE2MainbyBillPeriodBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectT3ByBillPeriodCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectT3ByBillPeriodCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectT3ByBillPeriodCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectT3PermanentByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectT3PermanentByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectT3PermanentByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardReg_SelectT3TemporaryByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardReg_SelectT3TemporaryByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardReg_SelectT3TemporaryByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_Generate
		(
			int BillPeriodID,
			ref string GenerateOutput
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_Generate", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@GenerateOutput", SqlDbType.VarChar, -1, -1, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				GenerateOutput = get_string_value(sqlCmd.Parameters["@GenerateOutput"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_Generate error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectNonSE2BackupbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectNonSE2BackupbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectNonSE2BackupbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectNonSE2BackupByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectNonSE2BackupByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectNonSE2BackupByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectNonSE2BackupbyBillPeriodBU
		(
			int BillPeriodID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectNonSE2BackupbyBillPeriodBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectNonSE2BackupbyBillPeriodBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectNonSE2MainbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectNonSE2MainbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectNonSE2MainbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectNonSE2MainByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectNonSE2MainByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectNonSE2MainByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectNonSE2MainbyBillPeriodBU
		(
			int BillPeriodID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectNonSE2MainbyBillPeriodBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectNonSE2MainbyBillPeriodBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectSE2BackupbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectSE2BackupbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectSE2BackupbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectSE2BackupByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectSE2BackupByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectSE2BackupByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectSE2BackupbyBillPeriodBU
		(
			int BillPeriodID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectSE2BackupbyBillPeriodBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectSE2BackupbyBillPeriodBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectSE2MainbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectSE2MainbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectSE2MainbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectSE2MainByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectSE2MainByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectSE2MainByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectSE2MainbyBillPeriodBU
		(
			int BillPeriodID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectSE2MainbyBillPeriodBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectSE2MainbyBillPeriodBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectT3ByBillPeriodCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectT3ByBillPeriodCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectT3ByBillPeriodCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectT3PermanentByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectT3PermanentByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectT3PermanentByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRpl_SelectT3TemporaryByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRpl_SelectT3TemporaryByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRpl_SelectT3TemporaryByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRps_Generate
		(
			int BillPeriodID,
			ref string GenerateOutput
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRps_Generate", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@GenerateOutput", SqlDbType.VarChar, -1, -1, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				GenerateOutput = get_string_value(sqlCmd.Parameters["@GenerateOutput"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRps_Generate error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRps_SelectNonSE2BackupbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRps_SelectNonSE2BackupbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRps_SelectNonSE2BackupbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRps_SelectNonSE2BackupByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRps_SelectNonSE2BackupByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRps_SelectNonSE2BackupByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRps_SelectNonSE2MainbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRps_SelectNonSE2MainbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRps_SelectNonSE2MainbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRps_SelectNonSE2MainByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRps_SelectNonSE2MainByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRps_SelectNonSE2MainByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRps_SelectSE2BackupbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRps_SelectSE2BackupbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRps_SelectSE2BackupbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRps_SelectSE2BackupByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRps_SelectSE2BackupByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRps_SelectSE2BackupByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRps_SelectSE2MainbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRps_SelectSE2MainbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRps_SelectSE2MainbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlyPSCardRps_SelectSE2MainByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlyPSCardRps_SelectSE2MainByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlyPSCardRps_SelectSE2MainByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlySE2_Generate
		(
			int BillPeriodID,
			ref string GenerateOutput
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlySE2_Generate", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@GenerateOutput", SqlDbType.VarChar, -1, -1, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				GenerateOutput = get_string_value(sqlCmd.Parameters["@GenerateOutput"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlySE2_Generate error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlySE2_IsExists
		(
			int BillPeriodID,
			ref int IsExists
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlySE2_IsExists", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@IsExists", SqlDbType.Int, 1, 1, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				IsExists = get_int_value(sqlCmd.Parameters["@IsExists"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlySE2_IsExists error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlySE2_SelectActivationOTCbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlySE2_SelectActivationOTCbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlySE2_SelectActivationOTCbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlySE2_SelectActivationOTCByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlySE2_SelectActivationOTCByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlySE2_SelectActivationOTCByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlySE2_SelectbyBillPeriodBillCustomer
		(
			int BillPeriodID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlySE2_SelectbyBillPeriodBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlySE2_SelectbyBillPeriodBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlySE2_SelectByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlySE2_SelectByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlySE2_SelectByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlySE2_SelectbyBillPeriodBU
		(
			int BillPeriodID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlySE2_SelectbyBillPeriodBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlySE2_SelectbyBillPeriodBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillMonthlySE2_SelectOTCByBillPeriodCostCentre
		(
			int BillPeriodID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillMonthlySE2_SelectOTCByBillPeriodCostCentre", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillMonthlySE2_SelectOTCByBillPeriodCostCentre error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillPeriod_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillPeriod_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillPeriod_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillPeriod_SelectCurrentPreiod
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillPeriod_SelectCurrentPreiod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillPeriod_SelectCurrentPreiod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillPeriod_SelectGeneratedDataPeriod
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillPeriod_SelectGeneratedDataPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillPeriod_SelectGeneratedDataPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillPeriod_SelectGeneratedPeriod
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillPeriod_SelectGeneratedPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillPeriod_SelectGeneratedPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillPeriod_SelectReleasedPeriodByBillingRecipientEmail
		(
			string Email
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillPeriod_SelectReleasedPeriodByBillingRecipientEmail", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@Email", SqlDbType.VarChar, 200, 200, 0, ParameterDirection.Input, Email);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillPeriod_SelectReleasedPeriodByBillingRecipientEmail error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillPeriod_SelectReleasedPeriodByBUID
		(
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillPeriod_SelectReleasedPeriodByBUID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillPeriod_SelectReleasedPeriodByBUID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportAgencyTransferRequest_SelectByBillPeriod
		(
			int BillPeriodID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportAgencyTransferRequest_SelectByBillPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportAgencyTransferRequest_SelectByBillPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportCCTransferRequest_SelectByBillPeriod
		(
			int BillPeriodID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportCCTransferRequest_SelectByBillPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportCCTransferRequest_SelectByBillPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportCertisManagementFee_SelectPSByBillPeriod
		(
			int BillPeriodID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportCertisManagementFee_SelectPSByBillPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportCertisManagementFee_SelectPSByBillPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportCertisPSCardRequestDetail_SelectByBillPeriod
		(
			int BillPeriodID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportCertisPSCardRequestDetail_SelectByBillPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportCertisPSCardRequestDetail_SelectByBillPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportCertisPSCardRequestSummary_SelectByBillPeriod
		(
			int BillPeriodID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportCertisPSCardRequestSummary_SelectByBillPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportCertisPSCardRequestSummary_SelectByBillPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportChangeRequest_SelectClosedByBillPeriod
		(
			int BillPeriodID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportChangeRequest_SelectClosedByBillPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportChangeRequest_SelectClosedByBillPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportFinanceSummaryPSNonSE2_SelectByBillPeriod
		(
			int BillPeriodID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportFinanceSummaryPSNonSE2_SelectByBillPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportFinanceSummaryPSNonSE2_SelectByBillPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportFinanceSummaryPSSE2_SelectByBillPeriod
		(
			int BillPeriodID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportFinanceSummaryPSSE2_SelectByBillPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportFinanceSummaryPSSE2_SelectByBillPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportFinanceSummarySE2_SelectByBillPeriod
		(
			int BillPeriodID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportFinanceSummarySE2_SelectByBillPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportFinanceSummarySE2_SelectByBillPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportPSProfileList_SelectByBillPeriod
		(
			int BillPeriodID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportPSProfileList_SelectByBillPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportPSProfileList_SelectByBillPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_Insert
		(
			int BillPeriodID,
			int BillReportTemplateID,
			string ReportFileName,
			object ReportData,
			string ContentType,
			int IsReleased,
			int BUID,
			int CostCentreID,
			int CreatedBy,
			string DownloadID,
			int BillCustomerID,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillReportTemplateID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
				AddParam(sqlCmd, "@ReportFileName", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ReportFileName);
				AddParam(sqlCmd, "@ReportData", SqlDbType.Binary, 16, 0, 0, ParameterDirection.Input, ReportData);
				AddParam(sqlCmd, "@ContentType", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ContentType);
				AddParam(sqlCmd, "@IsReleased", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, IsReleased);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@DownloadID", SqlDbType.VarChar, 72, 36, 0, ParameterDirection.Input, DownloadID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_ReleaseByID
		(
			int ID,
			int ReleasedBy,
			ref int UpdatedRow
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_ReleaseByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@ReleasedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ReleasedBy);
				AddParam(sqlCmd, "@UpdatedRow", SqlDbType.Int, 4, 10, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				UpdatedRow = get_int_value(sqlCmd.Parameters["@UpdatedRow"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_ReleaseByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_SelectAllReleasedWithoutDataByPeriodLoginGroupLoginEmailBillCustomer
		(
			int BillPeriodID,
			int LoginUserGroup,
			string Email,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_SelectAllReleasedWithoutDataByPeriodLoginGroupLoginEmailBillCustomer", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@LoginUserGroup", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, LoginUserGroup);
				AddParam(sqlCmd, "@Email", SqlDbType.VarChar, 200, 200, 0, ParameterDirection.Input, Email);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_SelectAllReleasedWithoutDataByPeriodLoginGroupLoginEmailBillCustomer error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_SelectAllReleasedWithoutDataByPeriodLoginGroupLoginBUAgencyBUCC
		(
			int BillPeriodID,
			int LoginUserGroup,
			int LoginBUID,
			int AgencyID,
			int BUID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_SelectAllReleasedWithoutDataByPeriodLoginGroupLoginBUAgencyBUCC", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@LoginUserGroup", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, LoginUserGroup);
				AddParam(sqlCmd, "@LoginBUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, LoginBUID);
				AddParam(sqlCmd, "@AgencyID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, AgencyID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_SelectAllReleasedWithoutDataByPeriodLoginGroupLoginBUAgencyBUCC error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_SelectAllWithoutDataByPeriodAgencyBUCC
		(
			int BillPeriodID,
			int AgencyID,
			int BUID,
			int CostCentreID,
			int FilterByIsReleased,
			int IsReleased
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_SelectAllWithoutDataByPeriodAgencyBUCC", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@AgencyID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, AgencyID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				AddParam(sqlCmd, "@FilterByIsReleased", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, FilterByIsReleased);
				AddParam(sqlCmd, "@IsReleased", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, IsReleased);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_SelectAllWithoutDataByPeriodAgencyBUCC error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_SelectBillingRecipientUserIdBySelectedRepositoryID
		(
			string SelectedRepositoryIDList
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_SelectBillingRecipientUserIdBySelectedRepositoryID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@SelectedRepositoryIDList", SqlDbType.VarChar, -1, -1, 0, ParameterDirection.Input, SelectedRepositoryIDList);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_SelectBillingRecipientUserIdBySelectedRepositoryID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_SelectByBillPeriodIDBillReportTemplateIDBillCustomerID
		(
			int BillPeriodID,
			int BillReportTemplateID,
			int BillCustomerID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_SelectByBillPeriodIDBillReportTemplateIDBillCustomerID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillReportTemplateID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
				AddParam(sqlCmd, "@BillCustomerID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_SelectByBillPeriodIDBillReportTemplateIDBillCustomerID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_SelectByBillPeriodIDBillReportTemplateIDBUIDCostCentreID
		(
			int BillPeriodID,
			int BillReportTemplateID,
			int BUID,
			int CostCentreID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_SelectByBillPeriodIDBillReportTemplateIDBUIDCostCentreID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillReportTemplateID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_SelectByBillPeriodIDBillReportTemplateIDBUIDCostCentreID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_SelectByIDDownloadID
		(
			int ID,
			string DownloadID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_SelectByIDDownloadID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@DownloadID", SqlDbType.VarChar, 72, 36, 0, ParameterDirection.Input, DownloadID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_SelectByIDDownloadID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_SelectBySelectedRepositoryIDBillingRecipientUserId
		(
			string SelectedRepositoryIDList,
			int UserId
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_SelectBySelectedRepositoryIDBillingRecipientUserId", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@SelectedRepositoryIDList", SqlDbType.VarChar, -1, -1, 0, ParameterDirection.Input, SelectedRepositoryIDList);
				AddParam(sqlCmd, "@UserId", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UserId);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_SelectBySelectedRepositoryIDBillingRecipientUserId error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_SelectBySelectedRepositoryIDGroupMemberID
		(
			string SelectedRepositoryIDList,
			int GroupMemberID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_SelectBySelectedRepositoryIDGroupMemberID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@SelectedRepositoryIDList", SqlDbType.VarChar, -1, -1, 0, ParameterDirection.Input, SelectedRepositoryIDList);
				AddParam(sqlCmd, "@GroupMemberID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_SelectBySelectedRepositoryIDGroupMemberID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_SelectBySelectedRepositoryIDGroupMemberIDBUID
		(
			string SelectedRepositoryIDList,
			int GroupMemberID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_SelectBySelectedRepositoryIDGroupMemberIDBUID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@SelectedRepositoryIDList", SqlDbType.VarChar, -1, -1, 0, ParameterDirection.Input, SelectedRepositoryIDList);
				AddParam(sqlCmd, "@GroupMemberID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_SelectBySelectedRepositoryIDGroupMemberIDBUID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_SelectGroupMemberIDWithNoBUIDBySelectedRepositoryID
		(
			string SelectedRepositoryIDList
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_SelectGroupMemberIDWithNoBUIDBySelectedRepositoryID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@SelectedRepositoryIDList", SqlDbType.VarChar, -1, -1, 0, ParameterDirection.Input, SelectedRepositoryIDList);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_SelectGroupMemberIDWithNoBUIDBySelectedRepositoryID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_SelectGroupMemberIDWithBUIDBySelectedRepositoryID
		(
			string SelectedRepositoryIDList
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_SelectGroupMemberIDWithBUIDBySelectedRepositoryID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@SelectedRepositoryIDList", SqlDbType.VarChar, -1, -1, 0, ParameterDirection.Input, SelectedRepositoryIDList);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_SelectGroupMemberIDWithBUIDBySelectedRepositoryID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_UnReleaseByID
		(
			int ID,
			int UnReleasedBy,
			ref int UpdatedRow
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_UnReleaseByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@UnReleasedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UnReleasedBy);
				AddParam(sqlCmd, "@UpdatedRow", SqlDbType.Int, 4, 10, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				UpdatedRow = get_int_value(sqlCmd.Parameters["@UpdatedRow"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_UnReleaseByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportRepository_UpdateByID
		(
			int ID,
			int BillPeriodID,
			int BillReportTemplateID,
			string ReportFileName,
			object ReportData,
			string ContentType,
			int IsReleased,
			int BUID,
			int CostCentreID,
			int CreatedBy,
			DateTime CreatedDateTime,
			int ReleasedBy,
			DateTime ReleasedDateTime
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportRepository_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				AddParam(sqlCmd, "@BillReportTemplateID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
				AddParam(sqlCmd, "@ReportFileName", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ReportFileName);
				AddParam(sqlCmd, "@ReportData", SqlDbType.Binary, 16, 0, 0, ParameterDirection.Input, ReportData);
				AddParam(sqlCmd, "@ContentType", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ContentType);
				AddParam(sqlCmd, "@IsReleased", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, IsReleased);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@CreatedDateTime", SqlDbType.DateTime, 8, 23, 3, ParameterDirection.Input, CreatedDateTime);
				AddParam(sqlCmd, "@ReleasedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ReleasedBy);
				AddParam(sqlCmd, "@ReleasedDateTime", SqlDbType.DateTime, 8, 23, 3, ParameterDirection.Input, ReleasedDateTime);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportRepository_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportSE2CreationRequest_SelectByBillPeriod
		(
			int BillPeriodID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportSE2CreationRequest_SelectByBillPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportSE2CreationRequest_SelectByBillPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportSE2ProfileList_SelectByBillPeriod
		(
			int BillPeriodID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportSE2ProfileList_SelectByBillPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportSE2ProfileList_SelectByBillPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportSE2TerminationRequest_SelectByBillPeriod
		(
			int BillPeriodID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportSE2TerminationRequest_SelectByBillPeriod", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillPeriodID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportSE2TerminationRequest_SelectByBillPeriod error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportTemplate_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportTemplate_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportTemplate_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportTemplate_Insert
		(
			string ReportName,
			string ReportPath,
			string RenderFormat,
			string ReportFileExt,
			string ContentType,
			string DatasetName,
			string StoredProcName,
			string ParameterType,
			int ReportStatus,
			string BillType,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportTemplate_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ReportName", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ReportName);
				AddParam(sqlCmd, "@ReportPath", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ReportPath);
				AddParam(sqlCmd, "@RenderFormat", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, RenderFormat);
				AddParam(sqlCmd, "@ReportFileExt", SqlDbType.VarChar, 20, 10, 0, ParameterDirection.Input, ReportFileExt);
				AddParam(sqlCmd, "@ContentType", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ContentType);
				AddParam(sqlCmd, "@DatasetName", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, DatasetName);
				AddParam(sqlCmd, "@StoredProcName", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, StoredProcName);
				AddParam(sqlCmd, "@ParameterType", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ParameterType);
				AddParam(sqlCmd, "@ReportStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, ReportStatus);
				AddParam(sqlCmd, "@BillType", SqlDbType.VarChar, 40, 20, 0, ParameterDirection.Input, BillType);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportTemplate_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportTemplate_SelectAllActive
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportTemplate_SelectAllActive", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportTemplate_SelectAllActive error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportTemplate_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportTemplate_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportTemplate_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportTemplate_UpdateByID
		(
			int ID,
			string ReportName,
			string ReportPath,
			string RenderFormat,
			string ReportFileExt,
			string ContentType,
			string DatasetName,
			string StoredProcName,
			string ParameterType,
			int ReportStatus,
			string BillType
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportTemplate_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@ReportName", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ReportName);
				AddParam(sqlCmd, "@ReportPath", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ReportPath);
				AddParam(sqlCmd, "@RenderFormat", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, RenderFormat);
				AddParam(sqlCmd, "@ReportFileExt", SqlDbType.VarChar, 20, 10, 0, ParameterDirection.Input, ReportFileExt);
				AddParam(sqlCmd, "@ContentType", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ContentType);
				AddParam(sqlCmd, "@DatasetName", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, DatasetName);
				AddParam(sqlCmd, "@StoredProcName", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, StoredProcName);
				AddParam(sqlCmd, "@ParameterType", SqlDbType.VarChar, 510, 255, 0, ParameterDirection.Input, ParameterType);
				AddParam(sqlCmd, "@ReportStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, ReportStatus);
				AddParam(sqlCmd, "@BillType", SqlDbType.VarChar, 40, 20, 0, ParameterDirection.Input, BillType);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportTemplate_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportUserGroup_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportUserGroup_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportUserGroup_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportUserGroup_Insert
		(
			int BillReportTemplateID,
			int GroupMemberID,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportUserGroup_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BillReportTemplateID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
				AddParam(sqlCmd, "@GroupMemberID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportUserGroup_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportUserGroup_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportUserGroup_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportUserGroup_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BillReportUserGroup_UpdateByID
		(
			int ID,
			int BillReportTemplateID,
			int GroupMemberID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BillReportUserGroup_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@BillReportTemplateID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
				AddParam(sqlCmd, "@GroupMemberID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BillReportUserGroup_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool SP_Content_Valid
		(
			int UserID,
			string ContentType,
			string ContentID,
			ref int Valid
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("SP_Content_Valid", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@UserID", SqlDbType.Int, 4, 10, 0, ParameterDirection.Input, UserID);
				AddParam(sqlCmd, "@ContentType", SqlDbType.VarChar, 100, 100, 0, ParameterDirection.Input, ContentType);
				AddParam(sqlCmd, "@ContentID", SqlDbType.VarChar, 100, 100, 0, ParameterDirection.Input, ContentID);
				AddParam(sqlCmd, "@Valid", SqlDbType.Int, 4, 10, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				Valid = get_int_value(sqlCmd.Parameters["@Valid"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "SP_Content_Valid error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentreInvoiceDetails_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentreInvoiceDetails_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentreInvoiceDetails_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentreInvoiceDetails_Insert
		(
			int CostCentreID,
			string InvoiceReceiptAddress,
			string InvoiceReceiptContact,
			string InvoiceReceiptEmail,
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentreInvoiceDetails_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				AddParam(sqlCmd, "@InvoiceReceiptAddress", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, InvoiceReceiptAddress);
				AddParam(sqlCmd, "@InvoiceReceiptContact", SqlDbType.VarChar, 30, 15, 0, ParameterDirection.Input, InvoiceReceiptContact);
				AddParam(sqlCmd, "@InvoiceReceiptEmail", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, InvoiceReceiptEmail);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentreInvoiceDetails_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentreInvoiceDetails_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentreInvoiceDetails_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentreInvoiceDetails_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentreInvoiceDetails_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentreInvoiceDetails_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentreInvoiceDetails_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentreInvoiceDetails_UpdateByID
		(
			int ID,
			int CostCentreID,
			string InvoiceReceiptAddress,
			string InvoiceReceiptContact,
			string InvoiceReceiptEmail,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentreInvoiceDetails_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				AddParam(sqlCmd, "@InvoiceReceiptAddress", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, InvoiceReceiptAddress);
				AddParam(sqlCmd, "@InvoiceReceiptContact", SqlDbType.VarChar, 30, 15, 0, ParameterDirection.Input, InvoiceReceiptContact);
				AddParam(sqlCmd, "@InvoiceReceiptEmail", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, InvoiceReceiptEmail);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentreInvoiceDetails_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentresInBU_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentresInBU_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentresInBU_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentresInBU_Insert
		(
			int BUID,
			string CostCentreIDName,
			string CostCentreName,
			int CostCentreStatus,
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentresInBU_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@CostCentreIDName", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, CostCentreIDName);
				AddParam(sqlCmd, "@CostCentreName", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, CostCentreName);
				AddParam(sqlCmd, "@CostCentreStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, CostCentreStatus);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 4, 10, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentresInBU_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentresInBU_SelectActiveByBUID
		(
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentresInBU_SelectActiveByBUID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentresInBU_SelectActiveByBUID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentresInBU_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentresInBU_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentresInBU_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentresInBU_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentresInBU_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentresInBU_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentresInBU_SelectByBUID
		(
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentresInBU_SelectByBUID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentresInBU_SelectByBUID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentresInBU_SelectAgencyBUCCByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentresInBU_SelectAgencyBUCCByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentresInBU_SelectAgencyBUCCByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentresInBU_SelectAgencyBUCCByAgencyID
		(
			int AgencyID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentresInBU_SelectAgencyBUCCByAgencyID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@AgencyID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, AgencyID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentresInBU_SelectAgencyBUCCByAgencyID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_CostCentresInBU_UpdateByID
		(
			int ID,
			int BUID,
			string CostCentreIDName,
			string CostCentreName,
			int CostCentreStatus,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_CostCentresInBU_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@CostCentreIDName", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, CostCentreIDName);
				AddParam(sqlCmd, "@CostCentreName", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, CostCentreName);
				AddParam(sqlCmd, "@CostCentreStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, CostCentreStatus);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_CostCentresInBU_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool sp_creatediagram
		(
			string diagramname,
			int owner_id,
			int version,
			object definition
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("sp_creatediagram", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@diagramname", SqlDbType.VarChar, 256, 128, 0, ParameterDirection.Input, diagramname);
				AddParam(sqlCmd, "@owner_id", SqlDbType.Int, 4, 10, 0, ParameterDirection.Input, owner_id);
				AddParam(sqlCmd, "@version", SqlDbType.Int, 4, 10, 0, ParameterDirection.Input, version);
				AddParam(sqlCmd, "@definition", SqlDbType.VarBinary, -1, -1, 0, ParameterDirection.Input, definition);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "sp_creatediagram error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_DomainsInBU_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_DomainsInBU_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_DomainsInBU_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_DomainsInBU_Insert
		(
			int BUID,
			string DomainName,
			int DomainStatus,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_DomainsInBU_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@DomainName", SqlDbType.VarChar, 200, 200, 0, ParameterDirection.Input, DomainName);
				AddParam(sqlCmd, "@DomainStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, DomainStatus);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 4, 10, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_DomainsInBU_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_DomainsInBU_SelectActiveByBUID
		(
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_DomainsInBU_SelectActiveByBUID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_DomainsInBU_SelectActiveByBUID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_DomainsInBU_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_DomainsInBU_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_DomainsInBU_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_DomainsInBU_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_DomainsInBU_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_DomainsInBU_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool SP_DomainsInBU_SelectByBUID
		(
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("SP_DomainsInBU_SelectByBUID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "SP_DomainsInBU_SelectByBUID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_DomainsInBU_UpdateByID
		(
			int ID,
			int BUID,
			string DomainName,
			int DomainStatus
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_DomainsInBU_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@DomainName", SqlDbType.VarChar, 200, 200, 0, ParameterDirection.Input, DomainName);
				AddParam(sqlCmd, "@DomainStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, DomainStatus);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_DomainsInBU_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool sp_dropdiagram
		(
			string diagramname,
			int owner_id
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("sp_dropdiagram", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@diagramname", SqlDbType.VarChar, 256, 128, 0, ParameterDirection.Input, diagramname);
				AddParam(sqlCmd, "@owner_id", SqlDbType.Int, 4, 10, 0, ParameterDirection.Input, owner_id);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "sp_dropdiagram error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_GeneralStatus_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_GeneralStatus_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_GeneralStatus_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_GroupMember_DeleteByID
		(
			int GroupID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_GroupMember_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@GroupID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_GroupMember_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_GroupMember_Insert
		(
			string GroupName,
			int CreatedBy,
			int GroupStatus,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_GroupMember_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@GroupName", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, GroupName);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@GroupStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, GroupStatus);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_GroupMember_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_GroupMember_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_GroupMember_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_GroupMember_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_GroupMember_SelectByID
		(
			int GroupID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_GroupMember_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@GroupID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_GroupMember_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_GroupMember_UpdateByID
		(
			int GroupID,
			string GroupName,
			int GroupStatus,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_GroupMember_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@GroupID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupID);
				AddParam(sqlCmd, "@GroupName", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, GroupName);
				AddParam(sqlCmd, "@GroupStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, GroupStatus);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_GroupMember_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_GroupMemberInResourcePermission_DeleteByID
		(
			int GroupMemberID,
			int ResourceID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_GroupMemberInResourcePermission_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@GroupMemberID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
				AddParam(sqlCmd, "@ResourceID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ResourceID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_GroupMemberInResourcePermission_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_GroupMemberInResourcePermission_GetByID
		(
			int GroupMemberID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_GroupMemberInResourcePermission_GetByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@GroupMemberID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_GroupMemberInResourcePermission_GetByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_GroupMemberInResourcePermission_Insert
		(
			int GroupMemberID,
			int ResourceID,
			int Create0,
			int Read0,
			int Update0,
			int Delete0,
			int Status,
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_GroupMemberInResourcePermission_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@GroupMemberID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
				AddParam(sqlCmd, "@ResourceID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ResourceID);
				AddParam(sqlCmd, "@Create0", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Create0);
				AddParam(sqlCmd, "@Read0", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Read0);
				AddParam(sqlCmd, "@Update0", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Update0);
				AddParam(sqlCmd, "@Delete0", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Delete0);
				AddParam(sqlCmd, "@Status", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Status);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_GroupMemberInResourcePermission_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_GroupMemberInResourcePermission_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_GroupMemberInResourcePermission_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_GroupMemberInResourcePermission_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_GroupMemberInResourcePermission_SelectByID
		(
			int GroupMemberID,
			int ResourceID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_GroupMemberInResourcePermission_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@GroupMemberID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
				AddParam(sqlCmd, "@ResourceID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ResourceID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_GroupMemberInResourcePermission_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool sp_GroupMemberInResourcePermission_UpdateByID
		(
			int GroupMemberID,
			int ResourceID,
			int Create0,
			int Read0,
			int Update0,
			int Delete0,
			int Status,
			int ModifiedBy,
			int xGroupMemberID,
			int xResourceID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("sp_GroupMemberInResourcePermission_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@GroupMemberID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
				AddParam(sqlCmd, "@ResourceID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ResourceID);
				AddParam(sqlCmd, "@Create0", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Create0);
				AddParam(sqlCmd, "@Read0", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Read0);
				AddParam(sqlCmd, "@Update0", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Update0);
				AddParam(sqlCmd, "@Delete0", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Delete0);
				AddParam(sqlCmd, "@Status", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Status);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				AddParam(sqlCmd, "@xGroupMemberID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, xGroupMemberID);
				AddParam(sqlCmd, "@xResourceID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, xResourceID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "sp_GroupMemberInResourcePermission_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool sp_helpdiagramdefinition
		(
			string diagramname,
			int owner_id
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("sp_helpdiagramdefinition", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@diagramname", SqlDbType.VarChar, 256, 128, 0, ParameterDirection.Input, diagramname);
				AddParam(sqlCmd, "@owner_id", SqlDbType.Int, 4, 10, 0, ParameterDirection.Input, owner_id);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "sp_helpdiagramdefinition error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool sp_helpdiagrams
		(
			string diagramname,
			int owner_id
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("sp_helpdiagrams", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@diagramname", SqlDbType.VarChar, 256, 128, 0, ParameterDirection.Input, diagramname);
				AddParam(sqlCmd, "@owner_id", SqlDbType.Int, 4, 10, 0, ParameterDirection.Input, owner_id);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "sp_helpdiagrams error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_IsRecordExists
		(
			string tablename,
			string fieldname,
			string value
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_IsRecordExists", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@tablename", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, tablename);
				AddParam(sqlCmd, "@fieldname", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, fieldname);
				AddParam(sqlCmd, "@value", SqlDbType.VarChar, 300, 150, 0, ParameterDirection.Input, value);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_IsRecordExists error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_MasterProfile_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_MasterProfile_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_MasterProfile_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_MasterProfile_Insert
		(
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_MasterProfile_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_MasterProfile_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_MasterProfile_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_MasterProfile_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_MasterProfile_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_MasterProfile_UpdateByID
		(
			int ID,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_MasterProfile_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_MasterProfile_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool SP_Notice_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("SP_Notice_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "SP_Notice_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Notice_Insert
		(
			string Subject,
			string Body0,
			DateTime PublishDate,
			DateTime ExpiredDate,
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Notice_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@Subject", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, Subject);
				AddParam(sqlCmd, "@Body0", SqlDbType.VarChar, 16, 0, 0, ParameterDirection.Input, Body0);
				AddParam(sqlCmd, "@PublishDate", SqlDbType.DateTime, 8, 23, 3, ParameterDirection.Input, PublishDate);
				AddParam(sqlCmd, "@ExpiredDate", SqlDbType.DateTime, 8, 23, 3, ParameterDirection.Input, ExpiredDate);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Notice_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Notice_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Notice_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Notice_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Notice_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Notice_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Notice_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Notice_SelectByNoExpired
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Notice_SelectByNoExpired", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Notice_SelectByNoExpired error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Notice_UpdateByID
		(
			int ID,
			string Subject,
			string Body0,
			DateTime PublishDate,
			DateTime ExpiredDate,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Notice_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@Subject", SqlDbType.VarChar, 200, 100, 0, ParameterDirection.Input, Subject);
				AddParam(sqlCmd, "@Body0", SqlDbType.VarChar, 16, 0, 0, ParameterDirection.Input, Body0);
				AddParam(sqlCmd, "@PublishDate", SqlDbType.DateTime, 8, 23, 3, ParameterDirection.Input, PublishDate);
				AddParam(sqlCmd, "@ExpiredDate", SqlDbType.DateTime, 8, 23, 3, ParameterDirection.Input, ExpiredDate);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Notice_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Agency_Delete
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Agency_Delete", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 4, 10, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Agency_Delete error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Agency_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Agency_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 4, 10, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Agency_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Agency_Insert
		(
			string AgencyIDName,
			string AgencyName,
			int IsMinistry,
			int AgencyStatus,
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Agency_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@AgencyIDName", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, AgencyIDName);
				AddParam(sqlCmd, "@AgencyName", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, AgencyName);
				AddParam(sqlCmd, "@IsMinistry", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, IsMinistry);
				AddParam(sqlCmd, "@AgencyStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, AgencyStatus);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 4, 10, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Agency_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool SP_Agency_SelectActiveByID_BasedOnMinistry
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("SP_Agency_SelectActiveByID_BasedOnMinistry", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "SP_Agency_SelectActiveByID_BasedOnMinistry error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Agency_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Agency_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Agency_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Agency_SelectAllActive
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Agency_SelectAllActive", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Agency_SelectAllActive error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Agency_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Agency_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Agency_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool SP_Agency_SelectByID_BasedOnMinistry
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("SP_Agency_SelectByID_BasedOnMinistry", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "SP_Agency_SelectByID_BasedOnMinistry error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Agency_UpdateByID
		(
			int ID,
			string AgencyIDName,
			string AgencyName,
			int IsMinistry,
			int AgencyStatus,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Agency_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@AgencyIDName", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, AgencyIDName);
				AddParam(sqlCmd, "@AgencyName", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, AgencyName);
				AddParam(sqlCmd, "@IsMinistry", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, IsMinistry);
				AddParam(sqlCmd, "@AgencyStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, AgencyStatus);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Agency_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool sp_renamediagram
		(
			string diagramname,
			int owner_id,
			string new_diagramname
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("sp_renamediagram", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@diagramname", SqlDbType.VarChar, 256, 128, 0, ParameterDirection.Input, diagramname);
				AddParam(sqlCmd, "@owner_id", SqlDbType.Int, 4, 10, 0, ParameterDirection.Input, owner_id);
				AddParam(sqlCmd, "@new_diagramname", SqlDbType.VarChar, 256, 128, 0, ParameterDirection.Input, new_diagramname);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "sp_renamediagram error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ResourceMenu_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ResourceMenu_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ResourceMenu_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ResourceMenu_GetByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ResourceMenu_GetByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ResourceMenu_GetByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ResourceMenu_Insert
		(
			int Parent,
			string ResourceName,
			string PageURL,
			int PageOrder,
			int Status,
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ResourceMenu_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@Parent", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, Parent);
				AddParam(sqlCmd, "@ResourceName", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, ResourceName);
				AddParam(sqlCmd, "@PageURL", SqlDbType.VarChar, 300, 150, 0, ParameterDirection.Input, PageURL);
				AddParam(sqlCmd, "@PageOrder", SqlDbType.Int, 4, 10, 0, ParameterDirection.Input, PageOrder);
				AddParam(sqlCmd, "@Status", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Status);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ResourceMenu_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ResourceMenu_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ResourceMenu_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ResourceMenu_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ResourceMenu_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ResourceMenu_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ResourceMenu_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ResourceMenu_SelectByStructure
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ResourceMenu_SelectByStructure", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ResourceMenu_SelectByStructure error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ResourceMenu_SelectByStructureWithGroupMemberID
		(
			int GroupMemberID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ResourceMenu_SelectByStructureWithGroupMemberID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@GroupMemberID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ResourceMenu_SelectByStructureWithGroupMemberID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ResourceMenu_UpdateByID
		(
			int ID,
			int Parent,
			string ResourceName,
			string PageURL,
			int PageOrder,
			int Status,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ResourceMenu_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@Parent", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, Parent);
				AddParam(sqlCmd, "@ResourceName", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, ResourceName);
				AddParam(sqlCmd, "@PageURL", SqlDbType.VarChar, 300, 150, 0, ParameterDirection.Input, PageURL);
				AddParam(sqlCmd, "@PageOrder", SqlDbType.Int, 4, 10, 0, ParameterDirection.Input, PageOrder);
				AddParam(sqlCmd, "@Status", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Status);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ResourceMenu_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Role_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Role_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Role_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Role_GetByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Role_GetByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Role_GetByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Role_Insert
		(
			string RoleName,
			int Status,
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Role_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@RoleName", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, RoleName);
				AddParam(sqlCmd, "@Status", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Status);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Role_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Role_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Role_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Role_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Role_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Role_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Role_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_Role_UpdateByID
		(
			int ID,
			string RoleName,
			int Status,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_Role_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@RoleName", SqlDbType.VarChar, 100, 50, 0, ParameterDirection.Input, RoleName);
				AddParam(sqlCmd, "@Status", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, Status);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_Role_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_SelectSubmittedEffCostCentreTransferSR
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_SelectSubmittedEffCostCentreTransferSR", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_SelectSubmittedEffCostCentreTransferSR error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_SelectTop2ActivePSCardFromEachBU
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_SelectTop2ActivePSCardFromEachBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_SelectTop2ActivePSCardFromEachBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_SelectTop2ActiveSE2ProfFromEachBU
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_SelectTop2ActiveSE2ProfFromEachBU", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_SelectTop2ActiveSE2ProfFromEachBU error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ServiceFormStatus_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ServiceFormStatus_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ServiceFormStatus_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ServiceFormStatus_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ServiceFormStatus_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ServiceFormStatus_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ServiceFormType_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ServiceFormType_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ServiceFormType_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ServiceFormType_GetByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ServiceFormType_GetByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ServiceFormType_GetByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ServiceFormType_Insert
		(
			string ServiceFormType,
			string ServiceFormCode,
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ServiceFormType_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ServiceFormType", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, ServiceFormType);
				AddParam(sqlCmd, "@ServiceFormCode", SqlDbType.VarChar, 200, 100, 0, ParameterDirection.Input, ServiceFormCode);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ServiceFormType_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ServiceFormType_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ServiceFormType_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ServiceFormType_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ServiceFormType_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ServiceFormType_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ServiceFormType_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_ServiceFormType_UpdateByID
		(
			int ID,
			string ServiceFormType,
			string ServiceFormCode,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_ServiceFormType_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@ServiceFormType", SqlDbType.VarChar, 2, 1, 0, ParameterDirection.Input, ServiceFormType);
				AddParam(sqlCmd, "@ServiceFormCode", SqlDbType.VarChar, 2, 1, 0, ParameterDirection.Input, ServiceFormCode);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_ServiceFormType_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BUsInAgency_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BUsInAgency_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BUsInAgency_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BUsInAgency_GetByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BUsInAgency_GetByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BUsInAgency_GetByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BUsInAgency_Insert
		(
			int AgencyID,
			string BUIDName,
			string BUName,
			int BUStatus,
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BUsInAgency_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@AgencyID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, AgencyID);
				AddParam(sqlCmd, "@BUIDName", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, BUIDName);
				AddParam(sqlCmd, "@BUName", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, BUName);
				AddParam(sqlCmd, "@BUStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, BUStatus);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 4, 10, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BUsInAgency_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BUsInAgency_SelectActiveByAgencyID
		(
			int AgencyID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BUsInAgency_SelectActiveByAgencyID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@AgencyID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, AgencyID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BUsInAgency_SelectActiveByAgencyID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BUsInAgency_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BUsInAgency_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BUsInAgency_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BUsInAgency_SelectByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BUsInAgency_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BUsInAgency_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BUsInAgency_SelectByAgencyID
		(
			int AgencyID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BUsInAgency_SelectByAgencyID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@AgencyID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, AgencyID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BUsInAgency_SelectByAgencyID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_BUsInAgency_UpdateByID
		(
			int ID,
			int AgencyID,
			string BUIDName,
			string BUName,
			int BUStatus,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_BUsInAgency_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@AgencyID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, AgencyID);
				AddParam(sqlCmd, "@BUIDName", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, BUIDName);
				AddParam(sqlCmd, "@BUName", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, BUName);
				AddParam(sqlCmd, "@BUStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, BUStatus);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_BUsInAgency_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_SubscriptionPricing_DeleteByID
		(
			int ID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_SubscriptionPricing_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_SubscriptionPricing_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_SubscriptionPricing_Insert
		(
			int SRType,
			int PSCardTypeID,
			string CardUsage,
			int IsBackupCard,
			int IsMinistry,
			int IsUrgent,
			int PricingType,
			decimal UnitPrice,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_SubscriptionPricing_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@SRType", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, SRType);
				AddParam(sqlCmd, "@PSCardTypeID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, PSCardTypeID);
				AddParam(sqlCmd, "@CardUsage", SqlDbType.VarChar, 40, 20, 0, ParameterDirection.Input, CardUsage);
				AddParam(sqlCmd, "@IsBackupCard", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, IsBackupCard);
				AddParam(sqlCmd, "@IsMinistry", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, IsMinistry);
				AddParam(sqlCmd, "@IsUrgent", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, IsUrgent);
				AddParam(sqlCmd, "@PricingType", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, PricingType);
				AddParam(sqlCmd, "@UnitPrice", SqlDbType.Decimal, 9, 18, 0, ParameterDirection.Input, UnitPrice);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 4, 10, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_SubscriptionPricing_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_SubscriptionPricing_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_SubscriptionPricing_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_SubscriptionPricing_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_SubscriptionPricing_UpdateByID
		(
			int ID,
			int SRType,
			int PSCardTypeID,
			string CardUsage,
			int IsBackupCard,
			int IsMinistry,
			int IsUrgent,
			int PricingType,
			decimal UnitPrice
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_SubscriptionPricing_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@ID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ID);
				AddParam(sqlCmd, "@SRType", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, SRType);
				AddParam(sqlCmd, "@PSCardTypeID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, PSCardTypeID);
				AddParam(sqlCmd, "@CardUsage", SqlDbType.VarChar, 40, 20, 0, ParameterDirection.Input, CardUsage);
				AddParam(sqlCmd, "@IsBackupCard", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, IsBackupCard);
				AddParam(sqlCmd, "@IsMinistry", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, IsMinistry);
				AddParam(sqlCmd, "@IsUrgent", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, IsUrgent);
				AddParam(sqlCmd, "@PricingType", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, PricingType);
				AddParam(sqlCmd, "@UnitPrice", SqlDbType.Decimal, 9, 18, 0, ParameterDirection.Input, UnitPrice);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_SubscriptionPricing_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool sp_upgraddiagrams
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("sp_upgraddiagrams", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "sp_upgraddiagrams error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_DeleteByID
		(
			int UserID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@UserID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UserID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_DoLogin
		(
			string LoginID,
			string LoginPassword
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_DoLogin", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@LoginID", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, LoginID);
				AddParam(sqlCmd, "@LoginPassword", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, LoginPassword);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_DoLogin error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_GetByID
		(
			int UserID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_GetByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@UserID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UserID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_GetByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_Insert
		(
			string LoginId,
			string LoginPassword,
			string NRIC,
			string Name0,
			string Address01,
			string Address02,
			string PostCode,
			string PrimaryPhone,
			string SecondaryPhone,
			string FaxNumber,
			string Email,
			int UserTypeID,
			int AgencyID,
			int BUID,
			int CostCentreID,
			int UserStatus,
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@LoginId", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, LoginId);
				AddParam(sqlCmd, "@LoginPassword", SqlDbType.VarChar, 200, 200, 0, ParameterDirection.Input, LoginPassword);
				AddParam(sqlCmd, "@NRIC", SqlDbType.VarChar, 200, 200, 0, ParameterDirection.Input, NRIC);
				AddParam(sqlCmd, "@Name0", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, Name0);
				AddParam(sqlCmd, "@Address01", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, Address01);
				AddParam(sqlCmd, "@Address02", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, Address02);
				AddParam(sqlCmd, "@PostCode", SqlDbType.VarChar, 10, 10, 0, ParameterDirection.Input, PostCode);
				AddParam(sqlCmd, "@PrimaryPhone", SqlDbType.VarChar, 15, 15, 0, ParameterDirection.Input, PrimaryPhone);
				AddParam(sqlCmd, "@SecondaryPhone", SqlDbType.VarChar, 15, 15, 0, ParameterDirection.Input, SecondaryPhone);
				AddParam(sqlCmd, "@FaxNumber", SqlDbType.VarChar, 15, 15, 0, ParameterDirection.Input, FaxNumber);
				AddParam(sqlCmd, "@Email", SqlDbType.VarChar, 200, 200, 0, ParameterDirection.Input, Email);
				AddParam(sqlCmd, "@UserTypeID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UserTypeID);
				AddParam(sqlCmd, "@AgencyID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, AgencyID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				AddParam(sqlCmd, "@UserStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, UserStatus);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 4, 10, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_SelectActiveByGroupIDBUID
		(
			int GroupID,
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_SelectActiveByGroupIDBUID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@GroupID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, GroupID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_SelectActiveByGroupIDBUID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_SelectActiveKM
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_SelectActiveKM", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_SelectActiveKM error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_SelectAllKM
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_SelectAllKM", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_SelectAllKM error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_SelectAllKMByBUID
		(
			int BUID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_SelectAllKMByBUID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_SelectAllKMByBUID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_SelectBookingAdmin
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_SelectBookingAdmin", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_SelectBookingAdmin error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_SelectByEmail
		(
			string Email
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_SelectByEmail", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@Email", SqlDbType.VarChar, 200, 200, 0, ParameterDirection.Input, Email);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_SelectByEmail error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_SelectByID
		(
			int UserID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@UserID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UserID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_SelectByLoginID
		(
			string LoginID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_SelectByLoginID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@LoginID", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, LoginID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_SelectByLoginID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_UpdateByID
		(
			int UserID,
			string LoginId,
			string LoginPassword,
			string NRIC,
			string Name0,
			string Address01,
			string Address02,
			string PostCode,
			string PrimaryPhone,
			string SecondaryPhone,
			string FaxNumber,
			string Email,
			int UserTypeID,
			int AgencyID,
			int BUID,
			int CostCentreID,
			int UserStatus,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@UserID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UserID);
				AddParam(sqlCmd, "@LoginId", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, LoginId);
				AddParam(sqlCmd, "@LoginPassword", SqlDbType.VarChar, 200, 200, 0, ParameterDirection.Input, LoginPassword);
				AddParam(sqlCmd, "@NRIC", SqlDbType.VarChar, 200, 200, 0, ParameterDirection.Input, NRIC);
				AddParam(sqlCmd, "@Name0", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, Name0);
				AddParam(sqlCmd, "@Address01", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, Address01);
				AddParam(sqlCmd, "@Address02", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, Address02);
				AddParam(sqlCmd, "@PostCode", SqlDbType.VarChar, 10, 10, 0, ParameterDirection.Input, PostCode);
				AddParam(sqlCmd, "@PrimaryPhone", SqlDbType.VarChar, 15, 15, 0, ParameterDirection.Input, PrimaryPhone);
				AddParam(sqlCmd, "@SecondaryPhone", SqlDbType.VarChar, 15, 15, 0, ParameterDirection.Input, SecondaryPhone);
				AddParam(sqlCmd, "@FaxNumber", SqlDbType.VarChar, 15, 15, 0, ParameterDirection.Input, FaxNumber);
				AddParam(sqlCmd, "@Email", SqlDbType.VarChar, 200, 200, 0, ParameterDirection.Input, Email);
				AddParam(sqlCmd, "@UserTypeID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UserTypeID);
				AddParam(sqlCmd, "@AgencyID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, AgencyID);
				AddParam(sqlCmd, "@BUID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, BUID);
				AddParam(sqlCmd, "@CostCentreID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CostCentreID);
				AddParam(sqlCmd, "@UserStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, UserStatus);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_UpdateByLoginIDForPassword
		(
			string LoginID,
			string LoginPassword
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_UpdateByLoginIDForPassword", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@LoginID", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, LoginID);
				AddParam(sqlCmd, "@LoginPassword", SqlDbType.VarChar, 400, 200, 0, ParameterDirection.Input, LoginPassword);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_UpdateByLoginIDForPassword error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UserProfile_UpdateUserStatusByUserID
		(
			int UserID,
			int UserStatus,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UserProfile_UpdateUserStatusByUserID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@UserID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UserID);
				AddParam(sqlCmd, "@UserStatus", SqlDbType.Int, 1, 1, 0, ParameterDirection.Input, UserStatus);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UserProfile_UpdateUserStatusByUserID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UsersInRole_DeleteByID
		(
			int UserID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UsersInRole_DeleteByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@UserID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UserID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UsersInRole_DeleteByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UsersInRole_GetByID
		(
			int UserID,
			int RoleID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UsersInRole_GetByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@UserID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UserID);
				AddParam(sqlCmd, "@RoleID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, RoleID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UsersInRole_GetByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UsersInRole_Insert
		(
			int RoleID,
			int UserID,
			int CreatedBy,
			ref int xPrimaryKey
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UsersInRole_Insert", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@RoleID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, RoleID);
				AddParam(sqlCmd, "@UserID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UserID);
				AddParam(sqlCmd, "@CreatedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, CreatedBy);
				AddParam(sqlCmd, "@xPrimaryKey", SqlDbType.Int, 8, 19, 0, ParameterDirection.Output, null);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				xPrimaryKey = get_int_value(sqlCmd.Parameters["@xPrimaryKey"].Value);
				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UsersInRole_Insert error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UsersInRole_SelectAll
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UsersInRole_SelectAll", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UsersInRole_SelectAll error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UsersInRole_SelectByID
		(
			int UserID,
			int RoleID
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UsersInRole_SelectByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@UserID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UserID);
				AddParam(sqlCmd, "@RoleID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, RoleID);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UsersInRole_SelectByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_UsersInRole_UpdateByID
		(
			int UserID,
			int RoleID,
			int ModifiedBy
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_UsersInRole_UpdateByID", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				AddParam(sqlCmd, "@UserID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, UserID);
				AddParam(sqlCmd, "@RoleID", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, RoleID);
				AddParam(sqlCmd, "@ModifiedBy", SqlDbType.Int, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_UsersInRole_UpdateByID error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
		public bool Sp_WorkingTblManualReperso_Execute
		(
		)
		{
			SqlConnection conn = null;
			SqlTransaction tran = null;
			SqlCommand sqlCmd = null;
			try
			{
				conn = this.GetConnection();
				if (conn == null) return false;
				tran = this.GetTransaction();

				sqlCmd = new SqlCommand("Sp_WorkingTblManualReperso_Execute", conn);
				sqlCmd.CommandTimeout = this.ExecuteTimeout;
				sqlCmd.CommandType = CommandType.StoredProcedure;
				if (tran != null) sqlCmd.Transaction = tran;

				sqlCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 4);
				sqlCmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;
				sqlCmd.ExecuteNonQuery();

				int _temp = Convert.ToInt32(sqlCmd.Parameters["@RETURN_VALUE"].Value.ToString());
				return true;
			}
			catch (Exception ex)
			{
				this.LastErrorCode = -1;
				this.LastError = "Sp_WorkingTblManualReperso_Execute error.\r\n" + ex.ExceptionInfo();
				return false;
			}
			finally
			{
				if (sqlCmd != null) sqlCmd.Dispose();
				if (conn != null && !this.InTransaction)
				{
					conn.Close();
					conn.Dispose();
				}
			}
		}
	}
}